Don't catch AssertionError
John Arbash Meinel
john at arbash-meinel.com
Thu Dec 21 20:08:21 GMT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Attached is a patch that I had to write to get Dmitry's new tests to
pass, and I just wanted to bring up *why*.
When we run the test suite by the PQM, we actually run 'make check'
which runs the selftest 3 times:
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)
We run it without a locale to catch potential unicode assumption bugs,
and we run it in -O to turn off assertions, and make sure bzr still runs
cleanly.
One of Dmitry's tests made sure that calling a function when you had
bogus data raise AssertionError.
I'm glad he wrote that, because it pointed out that we were requiring
'assert' to protect us from invalid data, which is not a valid thing to
do. It is valid to check for arguments being correct, but not to check
that you are reading valid data from the user.
I just wanted to remind everyone that if you find yourself writing a
test that catches AssertionError, it is usually a sign that something is
wrong with the code.
I know of one place where we *have* to. But it is because paramiko has
an assert, rather than something we are doing.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFium1JdeBCYSNAAMRAnXAAJ4s7OpzUacOT5vgwAO7hXSe5+sdgACfe7qK
BCSl5sRoPlUTl8lxdWKsP+k=
=1nQH
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: check_for_bad_method.diff
Type: text/x-patch
Size: 3471 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061221/e6a46c09/attachment.bin
More information about the bazaar
mailing list