launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #04591
Re: Lighter tests with FakeLibrarian
On Sat, Sep 11, 2010 at 8:25 PM, Stuart Bishop
<stuart.bishop@xxxxxxxxxxxxx> wrote:
> On Sat, Sep 11, 2010 at 3:16 PM, Robert Collins
> <robert.collins@xxxxxxxxxxxxx> wrote:
>
>> This shows a behaviour of context managers that is undesirable for test suites:
>
> I had a hard to debug failure where a context manager was being used
> as a test fixture - it did some monkey patching and then cleaned up:
>
> @contextmanager
> def with_monkey_patched_thing():
> monkey_patch()
> yield
> revert_monkey_patch()
>
> The end result was the cleanup never got called if the test raised an
> exception. The yield needs to be in a try: finally: block to ensure
> cleanup occurs.
Ah, I see, I used contextmanager wrong. Le sigh - thanks.
-Rob
References
-
Lighter tests with FakeLibrarian
From: Jeroen Vermeulen, 2010-08-24
-
Re: Lighter tests with FakeLibrarian
From: Robert Collins, 2010-08-24
-
Re: Lighter tests with FakeLibrarian
From: Aaron Bentley, 2010-08-24
-
Re: Lighter tests with FakeLibrarian
From: Robert Collins, 2010-08-24
-
Re: Lighter tests with FakeLibrarian
From: Aaron Bentley, 2010-08-24
-
Re: Lighter tests with FakeLibrarian
From: Robert Collins, 2010-08-24
-
Re: Lighter tests with FakeLibrarian
From: Aaron Bentley, 2010-08-24
-
Re: Lighter tests with FakeLibrarian
From: Robert Collins, 2010-08-24
-
Re: Lighter tests with FakeLibrarian
From: Robert Collins, 2010-09-11
-
Re: Lighter tests with FakeLibrarian
From: Stuart Bishop, 2010-09-11