testing
Shared module for vsc software testing
TestCase: use instead of unittest TestCase from easybuild.base.testing import TestCase
Authors:
- Stijn De Weirdt (Ghent University)
- Kenneth Hoste (Ghent University)
TestCase
¶
Bases: TestCase
Enhanced test case, provides extra functionality (e.g. an assertErrorRegex method).
assertEqual(a, b, msg=None)
¶
Make assertEqual always print useful messages
assertErrorRegex(error, regex, call, *args, **kwargs)
¶
Convenience method to match regex with the expected error message. Example: self.assertErrorRegex(OSError, "No such file or directory", os.remove, '/no/such/file')
assertExists(path, msg=None)
¶
Assert the given path exists
assertNotExists(path, msg=None)
¶
Assert the given path exists
convert_exception_to_str(err)
¶
Convert an Exception instance to a string.
get_stderr()
¶
Return output captured from stderr until now.
get_stdout()
¶
Return output captured from stdout until now.
is_string(x)
¶
test if the variable x is a string)
mock_stderr(enable)
¶
Enable/disable mocking stdout.
mock_stdout(enable)
¶
Enable/disable mocking stdout.
mocked_stdout_stderr(mock_stdout=True, mock_stderr=True)
¶
Context manager to mock stdout and stderr
setUp()
¶
Prepare test case.
tearDown()
¶
Cleanup after running a test.
nicediff(txta, txtb, offset=5)
¶
generate unified diff style output ndiff has nice indicators what is different, but prints the whole content each line that is interesting starts with non-space unified diff only prints changes and some offset around it
return list with diff (one per line) (not a generator like ndiff or unified_diff)