Plain is headed towards 1.0! Subscribe for development updates →

 1# plain.pytest
 2
 3**Test with pytest.**
 4
 5Use the `plain test` command to run tests with pytest and automatically load a `.env.test` (if available).
 6
 7## Fixtures
 8
 9### `settings`
10
11Use the `settings` fixture to access and modify settings during tests.
12
13```python
14def test_example(settings):
15    settings.DEBUG = True
16    assert settings.DEBUG is True
17```
18
19### `testbrowser`
20
21A lightweight wrapper around [Playwright](https://playwright.dev/python/) that starts a gunicorn side-process to point the browser at.
22
23Note that `playwright`, `pytest-playwright`, and `gunicorn` are not dependencies of this package but are required if you want to use this fixture.
24
25```python
26def test_example(testbrowser):
27    page = testbrowser.new_page()
28    page.goto('/')
29    assert page.title() == 'Home Page'
30```
31
32If `plain.models` is installed, then the `testbrowser` will also load the [`isolated_db`](/plain-models/plain/models/test/pytest.py#isolated_db) fixture and pass a `DATABASE_URL` to the gunicorn process.