Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25532
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: assertraises behaviour |
| Date | 2012-07-17 14:39 -0400 |
| References | (2 earlier) <CAF_E5JZNrusmb2SziNBOah67ioZG0yf_w5RNJxVVrU8B5Tqzuw@mail.gmail.com> <ju1att$hc4$1@dough.gmane.org> <CAF_E5Ja4kzHGa9vEr5CML5wV7ampCULRRGt=9JtRoqn4Xxummw@mail.gmail.com> <ju1iug$mtd$1@dough.gmane.org> <CAF_E5JZ18C5z5ZKQ7P66UKZc3SLD3WUAWtD5hRSok8YOep1-Jg@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2243.1342550377.4697.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: assertraises behaviour Terry Reedy <tjreedy@udel.edu> - 2012-07-17 14:39 -0400
csiph-web