Message193969
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 |
|
Date |
User |
Action |
Args |
2013-07-31 01:22:37 | py.user | set | recipients:
+ py.user, terry.reedy, docs@python, python-dev |
2013-07-31 01:22:37 | py.user | set | messageid: <1375233757.49.0.730056275794.issue18573@psf.upfronthosting.co.za> |
2013-07-31 01:22:37 | py.user | link | issue18573 messages |
2013-07-31 01:22:36 | py.user | create | |
|