When writing unit tests, I was often using following pattern:
with self.subTest("Invalid input") and self.assertRaises(ValueError):
...
But only today I learned that according to python specs, I should be using ,
here:
with self.subTest("Invalid input"), self.assertRaises(ValueError):
...
And the specifications don't mention and
as an option. Yet the tests always seemed to be working fine.
What are the possible problems when using and
here? Why does it seem to usually work the same way as ,
?