← Back to team overview

launchpad-dev team mailing list archive

Re: Lighter tests with FakeLibrarian

 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/24/2010 03:43 PM, Robert Collins wrote:
> A context manager with its enter and exit is indeed a super set of a
> fixture as launchpad has defined them.

> However, writing
> def setUp(self):
>     bar = xx
>     foo = something(bar)
>     foo.__enter__()
>     self.addCleanup(foo__exit__, None, None, None)
> 
> is frankly ugly.

True, but this is exactly what useContext's for, so there's no need for
that ugliness.

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.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkx0I7MACgkQ0F+nu1YWqI110ACfVfT7nyImszNTZ+qoVlEhzwhn
jhYAmweagF/4RUuvehXKEmHjT9JoewJ4
=Oo9D
-----END PGP SIGNATURE-----



Follow ups

References