module pycode.utils_tests_private
¶
Short summary¶
module pyquickhelper.pycode.utils_tests_private
This extension contains various functionalities to help unittesting.
Functions¶
function |
truncated documentation |
---|---|
Does the cleaning. |
|
Default skip function for function |
|
Return an estimation of the processing time, it extracts the number in |
|
Returns the list of test files. |
|
Runs all tests in file list |
|
Checks if the text written on stderr is an error or not, a local server can push logs on this stream, it looks for … |
|
Runs all unit tests, the function looks into the folder _unittest and extract from all files beginning by test_ … |
Documentation¶
This extension contains various functionalities to help unittesting.
- pyquickhelper.pycode.utils_tests_private.clean(folder=None, fLOG=<function noLOG>)[source]¶
Does the cleaning.
- Parameters:
dir – directory
fLOG – logging function
- pyquickhelper.pycode.utils_tests_private.default_skip_function(name, code, duration)[source]¶
Default skip function for function
main_wrapper_tests
.- Parameters:
name – name of the test file
code – code of the test file
duration – estimated duration of the tests (specified in the file documentation)
- Returns:
True if skipped, False otherwise
- pyquickhelper.pycode.utils_tests_private.get_estimation_time(file)[source]¶
Return an estimation of the processing time, it extracts the number in
(time=5s)
for example.- Parameters:
file – filename
- Returns:
int
- pyquickhelper.pycode.utils_tests_private.get_test_file(filter, folder=None, no_subfolder=False, fLOG=<function noLOG>, root=None)[source]¶
Returns the list of test files.
- Parameters:
folder – path to look (or paths to look if it is a list)
filter – only select files matching the pattern (ex: test*)
no_subfolder – the function investigates the folder folder and does not try any subfolder in
{"_nrt", "_unittest", "_unittests"}
fLOG – logging function
root – root or folder which contains the project, rules applyong on folder name will not apply on it
- Returns:
a list of test files
- pyquickhelper.pycode.utils_tests_private.import_files(li, additional_ut_path=None, fLOG=<function noLOG>)[source]¶
Runs all tests in file list
li
.- Parameters:
li – list of files (python scripts)
additional_ut_path – additional paths to add when running the unit tests
fLOG – logging function
- Returns:
list of tests [ ( testsuite, file) ]
- pyquickhelper.pycode.utils_tests_private.is_valid_error(error)[source]¶
Checks if the text written on stderr is an error or not, a local server can push logs on this stream, it looks for keywords such as
Exception
,Error
,TraceBack
…- Parameters:
error – text
- Returns:
boolean
- pyquickhelper.pycode.utils_tests_private.main_run_test(runner, path_test=None, limit_max=1000000000.0, log=False, skip=-1, skip_list=None, on_stderr=False, processes=False, skip_function=None, additional_ut_path=None, stdout=None, stderr=None, filter_warning=None, fLOG=<function noLOG>)[source]¶
Runs all unit tests, the function looks into the folder _unittest and extract from all files beginning by test_ all methods starting by test_. Each files should mention an execution time. Tests are sorted by increasing order.
- Parameters:
runner – unittest Runner
path_test – path to look, if None, looks for defaults path related to this project
limit_max – avoid running tests longer than limit seconds
log – if True, enables intermediate files
skip – if skip != -1, skip the first “skip” test files
skip_list – skip unit test id in this list (by index, starting by 1)
skip_function – function(filename,content,duration) –> boolean to skip a unit test
on_stderr – if True, publish everything on stderr at the end
processes – to run the unit test in a separate process (with function
run_cmd
), however, to make that happen, you need to specifyexit=False
for each test file, see unittest.mainadditional_ut_path – additional paths to add when running the unit tests
stdout – if not None, use this stream instead of sys.stdout
stderr – if not None, use this stream instead of sys.stderr
filter_warning – function which removes some warnings in the final output, if None, the function filters out some recurrent warnings in jupyter (signature:
def filter_warning(w: warning) -> bool
),default_filter_warning
fLOG – logging function
- Returns:
dictionnary:
{ "err": err, "tests":list of couple (file, test results) }