On Wed, Aug 25, 2010 at 7:38 AM, Aaron Bentley <[email protected]> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 08/24/2010 03:33 PM, Robert Collins wrote:
>>> self.useContext(FakeLibrarian())
>>
>> I think both would be useful. I like context managers too, but
>> sometimes (perhaps not this case) its easier to express with a little
>> regular code in the middle.
>
> I don't understand. What is the regular code in the middle? Is a
> Context Manager not a superset of a fixture? If it is, surely we should
> prefer context managers, so there is one obvious correct way of doing
> things.
>
> Aaron
A context manager with its enter and exit is indeed a super set of a
fixture as launchpad has defined them. Its a subset of what I defined
them as in lp:python-fixtures (where they are defined as having both
protocols, so there still isn't anything you can do with one and not
the other).
However, writing
def setUp(self):
bar = xx
foo = something(bar)
foo.__enter__()
self.addCleanup(foo__exit__, None, None, None)
is frankly ugly.
-Rob
_______________________________________________
Mailing list: https://launchpad.net/~launchpad-dev
Post to : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-dev
More help : https://help.launchpad.net/ListHelp