make it trivial to use a context as a fixture

Bug #1221724 reported by Sean Dague
6
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.

Revision history for this message
Robert Collins (lifeless) wrote :

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 EnvironmentFixture("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

Changed in python-fixtures:
status: New → Incomplete
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.