pytest vs test runner

Hi, lately I’m using pytest, pytest-xdist and pytest-django as my default way of running my tests.
Usually I use functions like:

def test_some_view(client):
    url = reverse("entity-list")
    response = client.get(url)
    assert response.status_code == 200

pytest -k test_some_view

But django docs shows / test and unittest classes (django.test.TestCase).
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:

  • setUpTestData
  • installed_apps
  • databases

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 pytest over TestCase until now.