[BUG] python -O bzr selftest fails

Robey Pointer robey at lag.net
Mon Oct 31 06:35:08 GMT 2005


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


On 29 Oct 2005, at 12:26, Aaron Bentley wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> John A Meinel wrote:
>
>> https://launchpad.net/products/bzr/+bug/3685
>>
>> In summary, because python -O turns off assert statements, not all
>> commands are run in the test suite. There are several lines with  
>> "assert
>> <something>" where <something> has a side effect.
>>
>
> This feels like one of those "Doctor, it hurts when I do this" "So  
> stop
> doing that" situations.  Yes, we can turn assert into something else,
> but -O -O will still kill us hard, because we require docstrings to
> exist (e.g. in BzrNewError).
>
> I'm inclined to do:
> assersions_work = False
> try:
>   assert False
> except:
>   assertions_work = True
> if not assertions_work:
>   raise BzrCommandError("Bzr selftest cannot be executed with -O")
>
> It just seems dumb to me that we have built-in language support for
> assertions, but we can't use them where they're most convenient.

It's really two different meanings for assert, as you pointed out  
yourself later in the thread. :)  One is for validating inputs and  
assumptions, the other for unit testing.  I definitely agree that  
unit tests shouldn't be using raw 'assert'.

robey

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Darwin)

iD8DBQFDZbsfQQDkKvyJ6cMRAuGBAKCyHmoqWPMLGONf6nYymGD/RLi+9ACgzVpQ
kazHe+E2kVYmCvYpbU/quVc=
=b5I8
-----END PGP SIGNATURE-----




More information about the bazaar mailing list