make it trivial to use a context as a fixture
Bug #1221724 reported by
Sean Dague
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python Fixtures |
Incomplete
|
Undecided
|
Unassigned |
Bug Description
There are many times where we need to run a test within a context, however doing so means that the addCleanup functions will actually execute outside that context. While it is possible to build a wrapper to turn a context into a fixture, it would be really great to have fixtures have a bullet proof way of using a context directly as a fixture to make this simpler for test writers.
Tripped over this when using the oslo lockutils in tempest to synchronize aggregates tests.
Changed in python-fixtures: | |
status: | New → Incomplete |
To post a comment you must log in.
Sorry, I can't quite make heads or tails of that.
Do you mean:
"I want to be able to use a Fixture as a context manager" ? If so - you can e.g.:
with EnvironmentFixt ure("Foo" ):
do_stuff_here()
Or do you mean you have a context manager 'mgr' and you want to use that as a fixture - like
self.useFixture (ContextFixture (mgr)) ? # ContextFixture is made up