Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25415
| Date | 2012-07-16 14:38 +0100 |
|---|---|
| Subject | assertraises behaviour |
| From | andrea crotti <andrea.crotti.0@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2172.1342445899.4697.python-list@python.org> (permalink) |
I found that the behaviour of assertRaises used as a context manager a
bit surprising.
This small example doesn't fail, but the OSError exception is cathed
even if not declared..
Is this the expected behaviour (from the doc I would say it's not).
(Running on arch-linux 64 bits and Python 2.7.3, but it doesn the same
with Python 3.2.3)
import unittest
class TestWithRaises(unittest.TestCase):
def test_ass(self):
with self.assertRaises(AssertionError):
assert False, "should happen"
raise OSError("should give error")
if __name__ == '__main__':
unittest.main()
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
assertraises behaviour andrea crotti <andrea.crotti.0@gmail.com> - 2012-07-16 14:38 +0100
csiph-web