cleanups not called when setUp fails with useFixture

Bug #1456353 reported by Cedric Brandily
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python Fixtures
Invalid
Undecided
Cedric Brandily

Bug Description

When we do:

  fixture1.useFixture(fixture2)

fixture2 cleanups are only called if fixture1.addCleanup(fixture2.cleanUp) is called ... but it's done in Fixture[1] only if fixture2.setUp() succeed.

[1] http://bazaar.launchpad.net/~testing-cabal/python-fixtures/master/view/head:/fixtures/fixture.py

Related branches

description: updated
Changed in python-fixtures:
assignee: nobody → Cedric Brandily (cbrandily)
Revision history for this message
Cedric Brandily (cbrandily) wrote :
Revision history for this message
John Schwarz (jschwarz) wrote :

I would like to comment that this sounds like a great idea. We've stumbled upon this issue here: [1], and specifically the discussion about this is here: [2].

I do think that this is quite an API change - developers might not except this change to happen (for example, a cleanUp code that was registered assumes that a setUp has been successful and won't check for it, causing the cleanUp to fail). I wonder if there's a non-invasive way to fix this gradually (maybe add a flag to useFixture that would, over time, become the default?)
This might be off base though, so I'd like to hear thoughts about this from others as well.

[1]: https://review.openstack.org/#/c/181991/
[2]: https://review.openstack.org/#/c/181991/1..4/neutron/tests/fullstack/fullstack_fixtures.py

Changed in python-fixtures:
status: New → In Progress
Revision history for this message
Robert Collins (lifeless) wrote :

I wanted to capture the logic here for easy later review..., so I did a blog post. https://rbtcollins.wordpress.com/2015/06/22/revisiting-the-fixture-api-handling-leaky-resources/

This particular bug is invalid: useFixture isn't and shouldn't be responsible for figuring out the right way to deal with a failed fixture: since we need to solve the with: case, there's no need for the useFixture code to be any different to with:, other than that its spread out over two call sites.

Changed in python-fixtures:
status: In Progress → Invalid
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.