How to skip a test method if another previous test method failed with unittest in Python?

Viewed 1625

I have one unittest test case with two different methods. I'd like that my second method to be skipped, if the first one fails.

I am using the decorator @unittest.skipIf but I cannot find the proper condition for it.

class myTest(unittest.TestCase):
    def test_1(self):
        self.assertEqual(1,2)

    @unittest.skipIf(????,'test_2 was skipped because test_1 failed')
    def test_2(self):
        pass

 if __name__ == '__main__':
    unittest.main()
1 Answers
Related