tests.lib package¶
Submodules¶
tests.lib.filelist module¶
-
tests.lib.filelist.
testfilelist
(filterfunc=None)¶ A generator function for the list of file names to check.
If the check is run from a git work tree, the method returns a list of files known to git. Otherwise, it returns a list of every file beneath $top_srcdir.
top_srcdir must be set in the environment.
filterfunc, if provided, is a function that takes a filename as an argument and returns True for files that should be included in the file list. For example, something like lambda x: fnmatch(x, ‘*.py’) could be used to match only filenames that end in .py.
tests.lib.gladecheck module¶
tests.lib.regexcheck module¶
-
tests.lib.regexcheck.
regex_group
(expression, test_cases)¶ Check that a regex parses strings into expected groups.
Test cases is a list of tuples of the form (test_string, expected_result) where expected_result is the groups tuples that should be returned by regex.match.
Parameters: - expression – a compiled expression object
- test_cases – a list of test strings and expected results
Returns: True if all test cases return the expected groups
Return type:
-
tests.lib.regexcheck.
regex_match
(expression, goodlist, badlist)¶ Check that a regular expression matches and does not match lists of strings.
This method will print a message for any failure and return a a bool to indicate whether the testcase passed.
Parameters: - expression – a compiled regular expression object
- goodlist – a list of strings expected to be matched by expression
- badlist – a list of strings expected not to be matched by expression
Returns: True if all strings in the lists matched or did not match as expected
Return type:
tests.lib.shutup module¶
-
tests.lib.shutup.
shutup
()¶ Run something with stdout and stderr redirected to /dev/null
The redirections will be process-wide, so this is not recommended for multithreaded applications.
tests.lib.timer module¶
-
tests.lib.timer.
timer
(seconds)¶ Return a timer context manager.
If the code within the context does not finish within the given number of seconds, it will raise an AssertionError.