Closed exarkun closed 5 years ago
For example, perhaps:
class FooTests(TestCase):
def setUp(self):
validator = eliot.testing.get_ready_for_validation()
self.addCleanup(validator.validate_it_now)
I suppose a class decorator could be another approach.
@eliot.testing.capture_logging_for_all_tests(None)
class FooTests(TestCase):
...
Having an API I can call at any point I want would also make this kind of testing more Twisted-friendly, I think. As far as I can tell, test methods that return a Deferred don't interact nicely with @capture_logging
.
OK, makes sense.
I would like to apply generic serialization validation to all tests in a particular
TestCase
. I could decorate every test with@capture_logging(None)
. It would be easier if I could instead just call some Eliot API in mytearDown
(or as a cleanup function withaddCleanup
). Perhaps this would need to be paired with somesetUp
API (I don't know). That would be fine. It still means two changes to my test suite instead of N.