[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I'm using unittest and the subtest context manager to run some tests: def test_spam(self): for i in range(100): for j in range(100): with self.subtest(i=i, j=j): self.assertEqual(spam(i, j), 999) Now, it turns out that spam(i, j) == 999 for all i, j *except* one or two exceptional cases. E.g. let's say spam(97, 83) != 999. And further, this is not a bug to be fixed, but an expected failure. I can write: def test_spam(self): for i in range(100): for j in range(100): with self.subtest(i=i, j=j): if (i, j) != (97, 83): self.assertEqual(spam(i, j), 999) but is there a nicer way to mark a specific subtest as an expected failure? I don't want the entire test_spam test to be counted as an expected failure, just that one subtest. https://docs.python.org/3/library/unittest.html#distinguishing-test-iterations-using-subtests -- Steve

- Prev by Date:
**the global keyword:** - Next by Date:
**ASCII or Unicode? (was best text editor for programming Python on a Mac)** - Previous by thread:
**Proposal: named return values through dict initialization and unpacking** - Next by thread:
**Marking a subtest as an expected failure** - Index(es):