[patch] fix testsuite under 'python -O'
John Arbash Meinel
john at arbash-meinel.com
Tue Oct 31 16:37:42 GMT 2006
Martin Pool wrote:
> This fixes some cases where we depend on side effects of 'assert', or
> test that it raises AssertionError.
>
> As a followon it might be good to change run_bzr_subprocess to pass -O
> if __debug__ is set.
>
> (Incidentally I occasionally see a 'bad file descriptor' when the test
> suite's simple http server thread is trying to listen on a socket. I'm
> not sure why - the code seems correct. Has anyone else seen it?)
>
>
The -O stuff is listed as a bug:
https://launchpad.net/products/bzr/+bug/45205
It is something I wanted to fix, but you seem to have beaten me to it.
Actually, what I would like to do is just add this line:
=== modified file 'Makefile'
--- Makefile 2006-10-16 06:38:32 +0000
+++ Makefile 2006-10-31 16:12:19 +0000
@@ -4,6 +4,7 @@
python -Werror ./bzr selftest -v $(tests)
@echo "Running all tests with no locale."
LC_CTYPE= LANG=C LC_ALL= ./bzr selftest -v $(tests)
+ python -O -Werror ./bzr selftest -v $(tests)
check-msgeditor:
./bzr --no-plugins selftest -v msgeditor
I've mentioned it in the past, and Robert was happy with it. It doesn't
add a huge overhead, and means that pqm will ensure our code base stays
-O clean.
>
> ------------------------------------------------------------------------
>
> === modified file 'bzrlib/builtins.py'
> --- bzrlib/builtins.py 2006-10-18 12:54:37 +0000
> +++ bzrlib/builtins.py 2006-10-31 05:23:05 +0000
> @@ -2412,9 +2412,12 @@
>
> class cmd_assert_fail(Command):
> """Test reporting of assertion failures"""
> + # intended just for use in testing
> +
> hidden = True
> +
> def run(self):
> - assert False, "always fails"
> + raise AssertionError("always fails")
^- I think a comment explaining that you want raise AssertionError
because in -O mode "assert" is optimized away.
>
>
> class cmd_help(Command):
>
> === modified file 'bzrlib/bzrdir.py'
> --- bzrlib/bzrdir.py 2006-10-12 03:19:14 +0000
> +++ bzrlib/bzrdir.py 2006-10-31 03:52:58 +0000
> @@ -1174,8 +1174,11 @@
> _found is a private parameter, do not use it.
> """
> if not _found:
> - assert isinstance(BzrDirFormat.find_format(transport),
> - self.__class__)
> + found_format = BzrDirFormat.find_format(transport)
> + if not isinstance(found_format, self.__class__):
> + raise AssertionError("%s was asked to open %s, but it seems to need "
> + "format %s"
> + % (self, transport, found_format))
> return self._open(transport)
>
> def _open(self, transport):
Otherwise the changes look good. So +1 from me.
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061031/902ca664/attachment.pgp
More information about the bazaar
mailing list