This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Ben.Darnell
Recipients Ben.Darnell
Date 2012-08-12.00:12:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1344730376.57.0.519562827761.issue15626@psf.upfronthosting.co.za>
In-reply-to
Content
In python 3.2, unittest.main by default modifies the warning configuration if no -W options were given on the command line.  This undoes the effect of -bb, turning BytesWarning back into a warning instead of an error.

If both -bb and -Werror::BytesWarning are given, then unittest does not tamper with the warning configuration and byte operations raise errors as expected (but note that -Werror doesn't work in the current version of virtualenv due to https://github.com/pypa/virtualenv/issues/194 ).  unittest.main should check for the -bb flag in addition to sys.warnoptions.

Additionally, if warning filters were modified programmatically before calling unittest.main, unittest will still modify the configuration and potentially override the user's settings.  This is a rarer case, but I've done it before to avoid the problem with -W in a virtualenv (https://github.com/facebook/tornado/blob/master/tornado/test/runtests.py).  It would be good for there to be some way to tell unittest.main not to touch the warnings at all.  main(warnings=False) currently works, but that's relying on an implementation detail (any non-None, non-truthy value works), so either this should be documented or an official way to do the same thing should be added.

The attached test file demonstrates the problem:  when run with -bb, an warning is logged, but the test passes.
History
Date User Action Args
2012-08-12 00:12:57Ben.Darnellsetrecipients: + Ben.Darnell
2012-08-12 00:12:56Ben.Darnellsetmessageid: <1344730376.57.0.519562827761.issue15626@psf.upfronthosting.co.za>
2012-08-12 00:12:55Ben.Darnelllinkissue15626 messages
2012-08-12 00:12:53Ben.Darnellcreate