In Python testing, why would you use assert methods:
self.assertEqual(response.status_code, 200)
self.assertIn('key', my_dict)
self.assertIsNotNone(thing)
As opposed to the direct assertions:
assert response.status_code == 200
assert 'key' in my_dict
assert thing is not None
According to the docs:
These methods are used instead of the assert statement so the test runner can accumulate all test results and produce a report
However this seems to be bogus, a test runner can accumulate results and produce a report regardless. In a related post unutbu has shown that unittest will raise an AssertionError
just the same as the assert statement will, and that was over 7 years ago so it's not a shiny new feature either.
With a modern test runner such as pytest, the failure messages generated by the assertion helper methods aren't any more readable (arguably the camelCase style of unittest is less readable). So, why not just use assert statements in your tests? What are the perceived disadvantages and why haven't important projects such as CPython moved away from unittest yet?