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 py.user
Recipients docs@python, py.user, python-dev, terry.reedy
Date 2013-07-31.01:22:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1375233757.49.0.730056275794.issue18573@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2013-07-31 01:22:37py.usersetrecipients: + py.user, terry.reedy, docs@python, python-dev
2013-07-31 01:22:37py.usersetmessageid: <1375233757.49.0.730056275794.issue18573@psf.upfronthosting.co.za>
2013-07-31 01:22:37py.userlinkissue18573 messages
2013-07-31 01:22:36py.usercreate