To clarify my "problem", I just thought that assertRaises if used as
context manager should behave as following:
- keep going if the exception declared is raised
- re-raise an error even if catched after the declared exception was catched
I was also confused by the doc a bit:
"Test that an excep
> On 17/07/2012 18:49, Prasad, Ramit wrote:
> >>> import unittest
> >>>
> >>> class TestWithRaises(unittest.TestCase):
> >>> def test_first(self):
> >>> assert False
> >>>
> >>> def test_second(self):
> >>> print("also called")
> >>> assert True
> >>>
> >>>
On 7/17/2012 5:06 AM, andrea crotti wrote:
Well this is what I meant:
import unittest
class TestWithRaises(unittest.TestCase):
def test_first(self):
assert False
def test_second(self):
print("also called")
assert True
if __name__ == '__main__':
unitt
On 17/07/2012 18:49, Prasad, Ramit wrote:
import unittest
class TestWithRaises(unittest.TestCase):
def test_first(self):
assert False
def test_second(self):
print("also called")
assert True
if __name__ == '__main__':
unittest.main()
in this case
> > import unittest
> >
> > class TestWithRaises(unittest.TestCase):
> > def test_first(self):
> > assert False
> >
> > def test_second(self):
> > print("also called")
> > assert True
> >
> > if __name__ == '__main__':
> > unittest.main()
> >
> > in this ca
Am 17.07.2012 11:06, schrieb andrea crotti:
import unittest
class TestWithRaises(unittest.TestCase):
def test_first(self):
assert False
def test_second(self):
print("also called")
assert True
if __name__ == '__main__':
unittest.main()
in this case als
2012/7/16 Peter Otten <__pete...@web.de>:
> No, I don't see how the code you gave above can fail with an OSError.
>
> Can you give an example that produces the desired behaviour with nose? Maybe
> we can help you translate it to basic unittest.
>
> --
> http://mail.python.org/mailman/listinfo/pytho
andrea crotti wrote:
> Good thanks, but there is something that implements this behaviour..
> For example nose runs all the tests, and if there are failures it goes
> on and shows the failed tests only in the end, so I think it is
> possible to achieve somehow, is that correct?
No, I don't see ho
Good thanks, but there is something that implements this behaviour..
For example nose runs all the tests, and if there are failures it goes
on and shows the failed tests only in the end, so I think it is
possible to achieve somehow, is that correct?
--
http://mail.python.org/mailman/listinfo/pytho
andrea crotti wrote:
> 2012/7/16 Christian Heimes :
>>
>> The OSError isn't catched as the code never reaches the line with "raise
>> OSError". In other words "raise OSError" is never executed as the
>> exception raised by "assert False" stops the context manager.
>>
>> You should avoid testing mo
2012/7/16 Christian Heimes :
>
> The OSError isn't catched as the code never reaches the line with "raise
> OSError". In other words "raise OSError" is never executed as the
> exception raised by "assert False" stops the context manager.
>
> You should avoid testing more than one line of code in a
Am 16.07.2012 15:38, schrieb andrea crotti:
> 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.
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, bu
13 matches
Mail list logo