py.user added the comment:
What about the second line?
It doesn't catch any exception
utest.py
#!/usr/bin/env python3
import unittest
class Test(unittest.TestCase):
def test_warning(self):
import warnings
with self.assertWarns(RuntimeWarning) as cm:
raise ValueError('f')
warnings.warn('f', RuntimeWarning)
print(repr(cm.warning))
[guest@localhost py]$ python3 -m unittest utest
E
======================================================================
ERROR: test_warning (utest.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "./utest.py", line 11, in test_warning
raise ValueError('f')
ValueError: f
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
[guest@localhost py]$
with commented raise
[guest@localhost py]$ python3 -m unittest utest
RuntimeWarning('f',)
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
[guest@localhost py]$
in the patch I copied terms from the first sentence of the paragraph
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18573>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com