Utilities for writting tests.
TestCase with subTest support for Python < 3.4.
Add subTest method to support parametric tests. API is the same, but behavior differs: If a subTest fails, the following ones are not run.
Context checking the number of logging messages from a specified Logger.
It disables propagation of logging message while running.
This is meant to be used as a with statement, for example:
>>> with TestLogging(logger, error=2, warning=0):
>>> pass # Run tests here expecting 2 ERROR and no WARNING from logger
...
Parameters: |
|
---|---|
Raises RuntimeError: | |
If the message counts are the expected ones. |
Decorator checking number of logging messages.
Propagation of logging messages is disabled by this decorator.
In case the expected number of logging messages is not found, it raises a RuntimeError.
>>> class Test(unittest.TestCase):
... @test_logging('module_logger_name', error=2, warning=0)
... def test(self):
... pass # Test expecting 2 ERROR and 0 WARNING messages
Parameters: |
|
---|