Merge lp:~cbrandily/python-fixtures/cleanup-context into lp:python-fixtures
Proposed by
Cedric Brandily
Status: | Needs review |
---|---|
Proposed branch: | lp:~cbrandily/python-fixtures/cleanup-context |
Merge into: | lp:python-fixtures |
Diff against target: |
80 lines (+54/-5) 2 files modified
fixtures/fixture.py (+6/-5) fixtures/tests/test_fixture.py (+48/-0) |
To merge this branch: | bzr merge lp:~cbrandily/python-fixtures/cleanup-context |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Collins | Disapprove | ||
Review via email: mp+259725@code.launchpad.net |
Description of the change
Ensure cleanups are called even if setUp fails with fixture context
This change ensures that a fixture cleanups will be called even if
its setUp fails when used as a context.
Example:
with MyFixture() as fixture1:
pass
fixture1.cleanUp will be called even if fixture1.setUp (called in
fixture1.__enter__) fails.
To post a comment you must log in.
Unmerged revisions
- 96. By Cedric Brandily
-
Ensure cleanups are called even if setUp fails with fixture context
This change ensures that a fixture cleanups will be called even if
its setUp fails when used as a context.Example:
with MyFixture() as fixture1:
passfixture1.cleanUp will be called even if fixture1.setUp (called in
fixture1.__enter__) fails.
Thanks for this patch. This is a better, closer to the cause fix. It doesn't address the issue of setUp being fragile though.
Additionally - and I'm sorry about this - you got mislead by the somewhat confusing thing of us having a mirror of the code here: the code is actually on github at https:/ /testing- cabal/fixtures. (LP does have a link to that but its not obvious - I hope I've made it clearer by editing the homepage a bit).
I've put up a patch https:/ /github. com/testing- cabal/fixtures/ pull/11 which I think fixes both angles systematically. It will require fixture authors to update, but they can do that incrementally in their own time, and the update is very easy. Reasoning behind this is at https:/ /rbtcollins. wordpress. com/2015/ 06/22/revisitin g-the-fixture- api-handling- leaky-resources /