[docs] [issue18573] In unittest.TestCase.assertWarns doc there is some text about assertRaises()
py.user
report at bugs.python.org
Wed Jul 31 03:22:37 CEST 2013
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 at 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 at localhost py]$
with commented raise
[guest at localhost py]$ python3 -m unittest utest
RuntimeWarning('f',)
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
[guest at localhost py]$
in the patch I copied terms from the first sentence of the paragraph
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18573>
_______________________________________
More information about the docs
mailing list