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


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

Re: assertraises behaviour

Started byTerry Reedy <tjreedy@udel.edu>
First post2012-07-17 14:39 -0400
Last post2012-07-17 14:39 -0400
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: assertraises behaviour Terry Reedy <tjreedy@udel.edu> - 2012-07-17 14:39 -0400

#25532 — Re: assertraises behaviour

FromTerry Reedy <tjreedy@udel.edu>
Date2012-07-17 14:39 -0400
SubjectRe: assertraises behaviour
Message-ID<mailman.2243.1342550377.4697.python-list@python.org>
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__':
>      unittest.main()
>
> in this case also the second test is run even if the first fails.

Or test_first is run even if test_second fails. The point is that 
unittest runs separate test methods independently. They could 
theoretically be run simultaneously.

Tests within a method are dependent unless you take steps to make them 
independent by not having them raise exceptions or by catching exception 
as you go until you are done. If you make a error_list of problems as 
you go, you could end the method with assertFalse(error_list).

-- 
Terry Jan Reedy


[toc] | [standalone]


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


csiph-web