New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unittest warnings counter #62581
Comments
...as per my original proposal on python-ideas: |
Looks good to me, except the backslash continuation is unneeded. Needs documentation. |
I get a test failure when I run the test suite with unittest.patch: test_Exit (unittest.test.test_program.Test_TestProgram) ... test test_unittest crashed -- Traceback (most recent call last):
File "/home/berker/projects/cpython-default/Lib/test/regrtest.py", line 1278, in runtest_inner
test_runner()
File "/home/berker/projects/cpython-default/Lib/test/test_unittest.py", line 8, in test_main
support.run_unittest(unittest.test.suite())
File "/home/berker/projects/cpython-default/Lib/test/support/__init__.py", line 1764, in run_unittest
_run_suite(suite)
File "/home/berker/projects/cpython-default/Lib/test/support/__init__.py", line 1730, in _run_suite
result = runner.run(suite)
File "/home/berker/projects/cpython-default/Lib/unittest/runner.py", line 178, in run
test(result)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 87, in __call__
return self.run(*args, **kwds)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 125, in run
test(result)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 87, in __call__
return self.run(*args, **kwds)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 125, in run
test(result)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 87, in __call__
return self.run(*args, **kwds)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 125, in run
test(result)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 87, in __call__
return self.run(*args, **kwds)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 125, in run
test(result)
File "/home/berker/projects/cpython-default/Lib/unittest/case.py", line 647, in __call__
return self.run(*args, **kwds)
File "/home/berker/projects/cpython-default/Lib/unittest/case.py", line 597, in run
testMethod()
File "/home/berker/projects/cpython-default/Lib/unittest/test/test_program.py", line 119, in test_Exit
testLoader=self.FooBarLoader())
File "/home/berker/projects/cpython-default/Lib/unittest/case.py", line 726, in assertRaises
return context.handle('assertRaises', callableObj, args, kwargs)
File "/home/berker/projects/cpython-default/Lib/unittest/case.py", line 173, in handle
callable_obj(*args, **kwargs)
File "/home/berker/projects/cpython-default/Lib/unittest/main.py", line 93, in __init__
self.runTests()
File "/home/berker/projects/cpython-default/Lib/unittest/main.py", line 244, in runTests
self.result = testRunner.run(self.test)
File "/home/berker/projects/cpython-default/Lib/unittest/runner.py", line 178, in run
test(result)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 87, in __call__
return self.run(*args, **kwds)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 125, in run
test(result)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 87, in __call__
return self.run(*args, **kwds)
File "/home/berker/projects/cpython-default/Lib/unittest/suite.py", line 125, in run
test(result)
File "/home/berker/projects/cpython-default/Lib/unittest/case.py", line 647, in __call__
return self.run(*args, **kwds)
File "/home/berker/projects/cpython-default/Lib/unittest/case.py", line 597, in run
testMethod()
File "/home/berker/projects/cpython-default/Lib/unittest/test/test_program.py", line 60, in testFail
assert False
AssertionError The new patch (see bpo-18381.diff) fixes that failure. Other changes:
|
FWICT Berker's patch LGTM. Michael, are you OK with committing this? |
Thanks for the review, Giampaolo. Attached a new patch which fixes text_logging and test_doctest tests. However, this patch will broke the current behavior of test.support.check_warnings. See Lib/test/test_xml_etree.py for example: test test_xml_etree crashed -- Traceback (most recent call last):
File "/home/berker/projects/cpython-default/Lib/test/regrtest.py", line 1278, in runtest_inner
test_runner()
File "/home/berker/projects/cpython-default/Lib/test/test_xml_etree.py", line 2580, in test_main
support.run_unittest(*test_classes)
File "/home/berker/projects/cpython-default/Lib/test/test_xml_etree.py", line 2537, in __exit__
self.checkwarnings.__exit__(*args)
File "/home/berker/projects/cpython-default/Lib/contextlib.py", line 66, in __exit__
next(self.gen)
File "/home/berker/projects/cpython-default/Lib/test/support/__init__.py", line 1081, in _filterwarnings
missing[0])
AssertionError: filter ("This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to '.+'", FutureWarning) did not catch any warning |
Ouch. I've just been bitten by the fact that unittest enables all warnings by default in 3.4, and this change would definitely make things worse. I would like to see a simple, documented way of disabling this new behaviour. I'm proposing a (it would be even nicer if this were more flexible, e.g. I want unittest to catch ResourceWarning but not NumbaWarning, but that's icing on the cake) By the way, perhaps the tests should also exercise the interaction with assertWarns() calls. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: