These docs are a work-in-progress and are currently undergoing a major rewrite!

Writing tests

The forge test command uses pytest (and pytest-django ) over the built-in test. Pytest can still execute the standard Django unittest classes, but you can also write tests using functions without needing as much boilerplate.

def test_homepage_exists(client):
    response = client.get("/")
    assert response.status_code in (200, 301, 302)

Common pytest options

Run the last failed test again:

forge test --last-failed
# Or
forge test --lf

Fail on the first test failure:

forge test --exitfirst
# Or
forge test -x

Run tests by name:

forge test -k homepage

Show all output (useful if you use ipdb somewhere in your tests):

forge test -s