HTMLTestRunner-rv
HTMLTestRunner.runner
to_unicode
to_unicode(s)
It strings to unicode
Arguments:
sstr - String to convert to unicode
Returns:
It returns unicode
OutputRedirector Objects
class OutputRedirector(object)
Wrapper to redirect stdout or stderr
__init__
__init__(fp)
Wrapper to redirect stdout or stderr
Arguments:
fpbuffer - Buffer to store stdout
write
write(s)
Write to string buffer with timestamp
Arguments:
sstr - String to write to buffer
Returns:
It returns None
writelines
writelines(lines)
It write number lines to buffer
Arguments:
lineslist - List of lines to write to buffer
Returns:
flush
flush()
It flushes string buffer
Returns:
_TestResult Objects
class _TestResult(TestResult)
__init__
__init__(verbosity=1, log_file='')
It generates test result
Arguments:
verbosityint - Ifverbosity > 1it logs all detailslog_filefile - File name to log thestdoutlogs
startTest
| startTest(test)
Start test inherited by unittest TestResult.
It changes stdout buffer to self.outputBuffer
Arguments:
test : Test object to do test
Returns:
complete_output
complete_output()
It disconnects self.outputBuffer from stdout and replaces with sys.stdout = sys.__stdout__,
sys.stderr = sys.__stderr__
writes buffer data to log file if self.log_file is True
Returns:
It returns buffer output
stopTest
stopTest(test)
Calls addSuccess() if testcase passed.
Calls addError() if gets error while testing.
Calls addFailure() if test has failed.
It disconnects self.outputBuffer from stdout and replaces with sys.__stdout__
Arguments:
test- Testcase to stop after it runs
Returns:
addSuccess
addSuccess(test)
It override method of class unittest.TestResult
It writes P in console
Arguments:
test- Testcase
Returns:
addError
addError(test, err)
It override method of class unittest.TestResult
It writes E in console
Arguments:
test- Testcase
Returns:
addFailure
addFailure(test, err)
It override method of class unittest.TestResult
It writes F in console
Arguments:
test- TestCase
Returns:
HTMLTestRunner Objects
class HTMLTestRunner()
__init__
__init__(log=None, output=None, verbosity=1, title=None, description=None, report_name='report', open_in_browser=False)
HTMLTestRunner
Arguments:
selfHTMLTestRunner - Object of HTMLTestRunnerlogbool - IfTrueit logs print buffer to *.txt file with timestampoutputstr - Report output dir nameverbosityint - Ifverbosity > 1it prints brief summary of testcases in consoletitlestr - Title of the Test Reportdescriptionstr - Description of Test Reportreport_namestr - Starting name of Test report and log fileopen_in_browserbool - IfTrueit opens report in browser automatically
Returns:
Runner object
run
run(test)
Run the Test Case
Arguments:
test- Test Case
Returns:
It returns result
sortResult
sortResult(result_list)
It sorts the Testcases to run
Arguments:
result_listlist - Results list
Returns:
Returns sorted result list
getReportAttributes
getReportAttributes(result)
Return report attributes as a list of (name, value). Override this to add custom attributes.
generateReport
generateReport(result)
It geneartes HTML report by using unittest report @param result:unittest result After generates html report it opens report in browser if open_in_broser is True It adds stylesheet and script files in reports directory