Hi, lately I’m using pytest, pytest-xdist and pytest-django as my default way of running my tests.
Usually I use functions like:
url = reverse("entity-list")
response = client.get(url)
assert response.status_code == 200
pytest -k test_some_view
But django docs shows
/manage.py test and unittest classes (
What are the advantages of using
TestCase and the default test runner? Is it just a style decision or there is something more?
Sorry if this is not the right place for asking these kind of questions! Or if someone already asked it.
TestCase has many features that haven’t been replicated in pytest-django. For example:
The more advanced your tests get, the more likely you’ll find one of these useful.
On the other hand, pytest has some neat features in fixtures, but there’s a workaround to use them with unittest TestCases.
My preference is pytest, with
TestCase classes for their features, but using the plain
assert style rather than the
self.assert* functions, since it’s less to remember.
My preference is
TestCase (from standard Python) as this implies one less dependency in my projects. I never found a killer feature in
TestCase until now.