module pycode.pytest_helper
¶
Short summary¶
module pyquickhelper.pycode.pytest_helper
pytest is sometimes slow. This file provides helpers to easily run test function.
Classes¶
class |
truncated documentation |
---|---|
Raised when the execution of a test fails. |
Functions¶
function |
truncated documentation |
---|---|
Runs test functions from module. |
Methods¶
method |
truncated documentation |
---|---|
Documentation¶
pytest is sometimes slow. This file provides helpers to easily run test function.
- exception pyquickhelper.pycode.pytest_helper.TestExecutionError(module, name, exc)[source]¶
Bases:
RuntimeError
Raised when the execution of a test fails.
- Parameters:
module – module
name – function name
exc – exception
- pyquickhelper.pycode.pytest_helper.run_test_function(module, pattern='^test_.*', stop_first=False, verbose=False, fLOG=<built-in function print>)[source]¶
Runs test functions from module.
- Parameters:
module – module (string or module)
pattern – function pattern
stop_first – stops at the first error or run all of them
verbose – prints out the name of the functions
fLOG – logging function
The following piece of code could also be used to run all tests not using any parameter.
fcts = [v for k, v in locals().items() if k.startswith('test_')] for fct in fcts: print("run", fct.__name__) try: fct() except Exception as e: if 'missing' in str(e): print(e) continue raise e