Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/OpenClassrooms-Student-Center/Python-OC-Lettings-FR/llms.txt

Use this file to discover all available pages before exploring further.

Orange County Lettings uses pytest with the pytest-django plugin to run its test suite. pytest-django handles Django setup automatically, including database creation and teardown, so you do not need to configure it manually.

Test configuration

The test runner is configured in setup.cfg:
[tool:pytest]
DJANGO_SETTINGS_MODULE = oc_lettings_site.settings
python_files = tests.py
addopts = -v
OptionDescription
DJANGO_SETTINGS_MODULEPoints pytest-django to the project settings file
python_filesTells pytest to collect tests from files named tests.py
addoptsRuns pytest in verbose mode (-v) by default
The pytest-django version used by this project is pytest-django==3.9.0.

Run the test suite

1

Change into the project directory

cd /path/to/Python-OC-Lettings-FR
2

Activate the virtual environment

source venv/bin/activate
3

Run pytest

pytest
pytest will discover and run all tests.py files found in the project.

Current tests

The existing test file at oc_lettings_site/tests.py contains a single placeholder test:
def test_dummy():
    assert 1
This test always passes and serves as a scaffold to confirm the test runner is working correctly.
Replace or extend test_dummy with real tests that exercise your views, models, and business logic. The example below shows how to test a Django view using the Django test client provided by pytest-django.

Example: testing a Django view

Use the client fixture provided by pytest-django to make HTTP requests against your views:
import pytest
from django.urls import reverse


@pytest.mark.django_db
def test_index_returns_200(client):
    url = reverse('index')
    response = client.get(url)
    assert response.status_code == 200
The @pytest.mark.django_db marker grants the test access to the database. The client fixture is a Django test.Client instance ready to make requests without starting a real server.

Build docs developers (and LLMs) love