module runner.py
HTMLTestRunner-rv module to generate HTML report for your testcase ==================================================================
The HTMLTestRunner provides easy way to generate HTML Test Reports. Easy to find errors and reduce the debug time. You no need to see console to see the debug messages, it logs every print logs in to *.txt with timestamp. So it is easy to debug whenever you want.
-
It automatically opens report in your browser so no need to search report file in your directory. Just you need to pass
open_in_browser = True. -
Color of Testcase block automatically change as per test result.
-
You can add your custom style Eg: style = "CSS styling"
-
You can add your custom script Eg: script = "javascript"
Global Variables
- stdout_redirector
- stderr_redirector
- STATUS
- DEFAULT_TITLE
- DEFAULT_DESCRIPTION
- PKG_PATH
function to_string
to_string(s)
It converts strings to unicode
Args:
s(str,byte): String to convert to unicode
Returns: It returns unicode
class HTMLTestRunner
function __init__
__init__(
log=None,
output=None,
verbosity=1,
title=None,
description=None,
style='',
script='',
report_name='report',
open_in_browser=False,
tested_by='Unknown',
add_traceback=False
)
HTMLTestRunner
Args:
self(HTMLTestRunner): Object of HTMLTestRunnerlog(bool): IfTrueit logs print buffer to *.txt file with timestampoutput(str): Report output dir nameverbosity(int): Ifverbosity > 1it prints brief summary of testcases in consoletitle(str): Title of the Test Reportdescription(str): Description of Test Reportstyle(str): Custom style for reportscript(str): Custom script for reportreport_name(str): Starting name of Test report and log fileopen_in_browser(bool): IfTrueit opens report in browser automaticallyadd_traceback(bool): Adds error trace back to report if True
Returns: Runner object
function generate_report
generate_report(result)
It generates HTML report by using unittest report @param result:unittest result After generates html report it opens report in browser if open_in_browser is True It adds stylesheet and script files in reports directory
function get_report_attributes
get_report_attributes(result)
Return report attributes as a list of (name, value). Override this to add custom attributes.
function run
run(test)
Run the Test Case
Args:
test: Test Case
Returns:
It returns result
function sort_result
sort_result(result_list)
It sorts the Testcases to run
Args:
result_list(list): Results list
Returns: Returns sorted result list
class OutputRedirector
Wrapper to redirect stdout or stderr
function __init__
__init__(fp)
Wrapper to redirect stdout or stderr
Args:
fp(buffer): Buffer to store stdout
function flush
flush()
It flushes string buffer
Returns:
function write
write(s)
Write to string buffer with timestamp
Args:
s(str): String to write to buffer
Returns: It returns None
function writelines
writelines(lines)
It writes number lines to buffer
Args:
lines(list): List of lines to write to buffer
Returns:
This file was automatically generated via lazydocs.