Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25415 > unrolled thread

assertraises behaviour

Started byandrea crotti <andrea.crotti.0@gmail.com>
First post2012-07-16 14:38 +0100
Last post2012-07-16 14:38 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  assertraises behaviour andrea crotti <andrea.crotti.0@gmail.com> - 2012-07-16 14:38 +0100

#25415 — assertraises behaviour

Fromandrea crotti <andrea.crotti.0@gmail.com>
Date2012-07-16 14:38 +0100
Subjectassertraises behaviour
Message-ID<mailman.2172.1342445899.4697.python-list@python.org>
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()

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web