summaryrefslogtreecommitdiff
path: root/fixtures/tests
diff options
context:
space:
mode:
authorBalazs Gibizer <balazs.gibizer@ericsson.com>2019-05-02 17:32:05 -0600
committerBalazs Gibizer <balazs.gibizer@ericsson.com>2019-05-02 17:38:46 -0600
commit6ffabae0f08880322680dc4c36260543cb6ab36d (patch)
treeb0552f5df543acaba79f8aa697f3880b1bb834ec /fixtures/tests
parent41774d58ed86b92dd60d727f00f1040f862c8ed1 (diff)
downloadfixtures-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.py9
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):