runner
Unit tests facility.
Attributes
mlogger = get_logger(__name__)
module-attribute
DEBUG_OKAY_RESULT = 'PASSED'
module-attribute
DEBUG_FAIL_RESULT = 'FAILED'
module-attribute
RESULT_TEST_SUITE_START = '<div class="unittest unitteststart">Test Suite: {suite}</div>'
module-attribute
RESULT_DIV_OKAY = '<div class="unittest unittestokay">:white_heavy_check_mark: PASSED {test}</div>'
module-attribute
RESULT_DIV_FAIL = '<div class="unittest unittestfail">:cross_mark: FAILED {test}</div>'
module-attribute
RESULT_DIV_ERROR = '<div class="unittest unittesterror">:heavy_large_circle: ERROR {test}</div>'
module-attribute
Classes
OutputWriter()
Output writer for tests results.
Source code in pyrevitlib/pyrevit/unittests/runner.py
Functions
write(output_str)
Prints the results to the output window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_str |
str
|
Text to output |
required |
PyRevitTestResult(verbosity)
Bases: TestResult
Pyrevit Test Result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbosity |
int
|
verbosity level. |
required |
Source code in pyrevitlib/pyrevit/unittests/runner.py
Attributes
writer = OutputWriter()
instance-attribute
Functions
getDescription(test)
staticmethod
Returns the description of the test.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test |
TestCase
|
Unit test. |
required |
Returns:
Type | Description |
---|---|
str
|
test description |
startTest(test)
Starts the test.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test |
TestCase
|
unit test |
required |
addSuccess(test)
Adds a test success.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test |
TestCase
|
unit test case |
required |
Source code in pyrevitlib/pyrevit/unittests/runner.py
addError(test, err)
Adds a test error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test |
TestCase
|
unit test case |
required |
err |
OptExcInfo
|
test exception info |
required |
Source code in pyrevitlib/pyrevit/unittests/runner.py
addFailure(test, err)
Adds a test failure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test |
TestCase
|
unit test case |
required |
err |
OptExcInfo
|
test exception info |
required |
Source code in pyrevitlib/pyrevit/unittests/runner.py
PyRevitTestRunner(verbosity=1, failfast=False, use_buffer=False, resultclass=None)
Bases: object
Test runner.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbosity |
int
|
level of vermosity. Defaults to 1. |
1
|
failfast |
bool
|
if True, stops at the first failure. Defaults to False. |
False
|
use_buffer |
bool
|
use a buffer. Defaults to False. |
False
|
resultclass |
type
|
Class to use to hold the results.
Defaults to |
None
|
Source code in pyrevitlib/pyrevit/unittests/runner.py
Attributes
resultclass = PyRevitTestResult
class-attribute
instance-attribute
verbosity = verbosity
instance-attribute
failfast = failfast
instance-attribute
use_buffer = use_buffer
instance-attribute
Functions
run(test)
Runs a test suite.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test |
TestSuite
|
Test suite to run |
required |
Returns:
Type | Description |
---|---|
PyRevitTestResult
|
Test suite results. |
Source code in pyrevitlib/pyrevit/unittests/runner.py
Functions
run_module_tests(test_module)
Runs the unit tests of the given module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test_module |
module
|
module with tests |
required |
Returns:
Type | Description |
---|---|
PyRevitTestResult
|
tests results. |
Source code in pyrevitlib/pyrevit/unittests/runner.py
run_test_case(test_case)
Runs the unit test of the given TestCase class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test_case |
type[TestCase]
|
TestCase class with tests |
required |
Returns:
Type | Description |
---|---|
PyRevitTestResult
|
tests results. |