diff options
author | Balazs Gibizer <balazs.gibizer@ericsson.com> | 2019-05-02 17:32:05 -0600 |
---|---|---|
committer | Balazs Gibizer <balazs.gibizer@ericsson.com> | 2019-05-02 17:38:46 -0600 |
commit | 6ffabae0f08880322680dc4c36260543cb6ab36d (patch) | |
tree | b0552f5df543acaba79f8aa697f3880b1bb834ec /fixtures/tests | |
parent | 41774d58ed86b92dd60d727f00f1040f862c8ed1 (diff) | |
download | fixtures-git-6ffabae0f08880322680dc4c36260543cb6ab36d.tar.gz |
Add possibility to reset the FakeLogger
A long test case might emit extensive logs that subunit does not
really handle well [1]. So it is useful to reset the logs stored
in the fixture at certain points in the test execution[2].
To be able to do that this patch adds reset_output() call to the
FakeLogger.
[1] https://bugs.launchpad.net/nova/+bug/1813147
[2] https://review.opendev.org/#/c/656844
Diffstat (limited to 'fixtures/tests')
-rw-r--r-- | fixtures/tests/_fixtures/test_logger.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fixtures/tests/_fixtures/test_logger.py b/fixtures/tests/_fixtures/test_logger.py index f8e11cc..251aec9 100644 --- a/fixtures/tests/_fixtures/test_logger.py +++ b/fixtures/tests/_fixtures/test_logger.py @@ -146,6 +146,15 @@ class FakeLoggerTest(TestCase, TestWithFixtures): with testtools.ExpectedException(TypeError): logging.info("Some message", "wrongarg") + def test_output_can_be_reset(self): + fixture = FakeLogger() + with fixture: + logging.info("message") + + fixture.reset_output() + + self.assertEqual("", fixture.output) + class LogHandlerTest(TestCase, TestWithFixtures): |