gitwtfhub

wtf is pytest_django?

dstufft/pytest_django — explained in plain English

Analysis updated 2026-07-18 · repo last pushed 2013-05-10

PythonAudience · developerComplexity · 1/5DormantSetup · easy

TL;DR

pytest-django lets Django developers run their tests with pytest instead of Django's built-in test runner, writing simpler test functions with less boilerplate.

Mindmap

mindmap
  root((pytest-django))
    What it does
      Pytest for Django
      Replaces manage.py test
      Test database reuse
    Tech stack
      Python
      Django
      Pytest
    Use cases
      Write simpler tests
      Run subset of tests
      Use pytest plugins
    Audience
      Django developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Switch an existing Django project's test suite from manage.py test to pytest without rewriting old tests.

REASON 2

Write simple Django test functions instead of class-based unittest tests.

REASON 3

Reuse the test database across runs to speed up a large Django test suite.

REASON 4

Combine Django testing with other pytest plugins for parallel runs or better reporting.

What's in the stack?

PythonDjangoPytest

How it stacks up

dstufft/pytest_django0xallam/my-recipe0xhassaan/nn-from-scratch
Stars0
LanguagePythonPythonPython
Last pushed2013-05-102022-11-22
MaintenanceDormantDormant
Setup difficultyeasymoderatemoderate
Complexity1/52/54/5
Audiencedevelopergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

Wtf does this do

pytest-django is a bridge that lets you run Django tests using pytest instead of Django's built-in test runner. If you've been using Django's manage.py test command, this plugin swaps that out for pytest, which is a more flexible and user-friendly testing tool. The practical benefit is that pytest requires less boilerplate and handles common testing tasks more cleanly. Instead of writing test classes that inherit from Django's test base, you just write simple test functions. pytest automatically finds your tests without requiring special imports, runs only the tests you specify if you want to skip some, and can reuse your test database across multiple test runs instead of rebuilding it each time. It also lets you inject dependencies into your tests more elegantly, which reduces repetitive setup code. Django developers would use this if they want a smoother testing experience. For example, a developer working on a Django project could install the plugin and immediately start writing tests as plain functions rather than class methods. If you're running a large test suite, you can run just the tests for a specific feature without running everything. The plugin also plays nicely with the many other pytest add-ons that exist in the ecosystem, so you get access to tools for things like parallel test execution, better reporting, or fixture management without extra effort. One key advantage is that it works alongside existing Django test code, you don't have to rewrite your current tests to switch. Old unittest-style tests will still run fine. The README doesn't go into detail about setup complexity, but the quick start suggests it's straightforward: install the package, set your Django settings module, and run pytest.

Yoink these prompts

Prompt 1
Help me set up pytest-django in my existing Django project and point it at my settings module.
Prompt 2
Show me how to write a simple Django view test as a pytest function instead of a Django TestCase class.
Prompt 3
Configure pytest-django to reuse the test database between runs so my test suite runs faster.
Prompt 4
Walk me through running only the tests for one Django app using pytest-django.

Frequently asked questions

wtf is pytest_django?

pytest-django lets Django developers run their tests with pytest instead of Django's built-in test runner, writing simpler test functions with less boilerplate.

What language is pytest_django written in?

Mainly Python. The stack also includes Python, Django, Pytest.

Is pytest_django actively maintained?

Dormant — no commits in 2+ years (last push 2013-05-10).

How hard is pytest_django to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is pytest_django for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.