launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #04468
Re: Lighter tests with FakeLibrarian
On Wed, Aug 25, 2010 at 7:55 AM, Aaron Bentley <aaron@xxxxxxxxxxxxx> wrote:
> I could argue that foo.__len__() is ugly if you use it directly, too. I
> think it is ugly to have two ways of doing the same thing. I really do.
> Context managers are inevitable, so having a Fixture concept that is
> equivalent but doesn't work the same is cognitive overhead and
> finger-typing overhead.
>
> Anything that is equivalent to a context manager should actually be a
> context manager, because that's what Python standardized on, and
> therefore it'll be compatible with everything going forward.
Oh, and I did forget something, lp:python-fixtures also defines a
reset(), which context managers do not define, and which is useful for
handling things like layers. Layers can be implemented on a fixture
with __enter__, __exit__ and reset(), but not on a bare context
manager.
I do agree that if something is equivalent to a context manager,
having it implement the contract is sensible - thats why Fixture
implements it :).
-Rob
Follow ups
References