assertraises behaviour
- From: andrea crotti <andrea.crotti.0@xxxxxxxxx>
- Date: Mon, 16 Jul 2012 14:38:17 +0100
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()
.
- Prev by Date: Re: Implicit conversion to boolean in if and while statements
- Next by Date: Re: assertraises behaviour
- Previous by thread: Diagramming code
- Next by thread: Re: assertraises behaviour
- Index(es):
Relevant Pages
|