Re: assertraises behaviour

Discussion in 'Python' started by Terry Reedy, Jul 17, 2012.

  1. Terry Reedy

    Terry Reedy Guest

    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
    Terry Reedy, Jul 17, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john
    Replies:
    2
    Views:
    1,958
  2. Inyeol
    Replies:
    3
    Views:
    312
    Chris Torek
    Oct 27, 2010
  3. andrea crotti

    Re: assertraises behaviour

    andrea crotti, Jul 16, 2012, in forum: Python
    Replies:
    0
    Views:
    167
    andrea crotti
    Jul 16, 2012
  4. Peter Otten

    Re: assertraises behaviour

    Peter Otten, Jul 16, 2012, in forum: Python
    Replies:
    0
    Views:
    173
    Peter Otten
    Jul 16, 2012
  5. andrea crotti

    Re: assertraises behaviour

    andrea crotti, Jul 17, 2012, in forum: Python
    Replies:
    4
    Views:
    194
    Prasad, Ramit
    Jul 17, 2012
Loading...

Share This Page