From 15f7a3df4831ea2c63c06c774a5f5a672ae6e1ec Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Tue, 28 Jan 2020 10:43:59 +0100 Subject: [PATCH] Override fixture context methods with setup/cleanup functions Change-Id: I68028cd86a6d065be3e2be4530d0632d46789e9d --- tobiko/common/_fixture.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tobiko/common/_fixture.py b/tobiko/common/_fixture.py index a2a72409b..1ccbd547e 100644 --- a/tobiko/common/_fixture.py +++ b/tobiko/common/_fixture.py @@ -379,6 +379,13 @@ class SharedFixture(fixtures.Fixture): self._cleanup_executed = True return result + def __enter__(self): + return setup_fixture(self) + + def __exit__(self, exc_type, exc_val, exc_tb): # noqa + cleanup_fixture(self) + return False # propagate exceptions from the with body. + def _setUp(self): self.setup_fixture()