Sample project for the CircleCI blog tutorial Pytest: Automated testing for Python.
It holds every example from the tutorial (fixtures, parametrized tests, and markers) and a CircleCI config that runs them with Smarter Testing, split across two containers.
| Path | Purpose |
|---|---|
test_example.py |
The first test from the tutorial. |
test_cache.py |
A fixture that gives each test a fresh SimpleCache. |
sum.py, test_sum.py |
A sum_two_numbers function and its test. |
swap.py, test_swap.py, test_swap_parametrized.py |
A swap_values function, a test, and a parametrized test. |
test_markers.py, test_slow.py |
Built-in skip and xfail markers, and a custom slow marker. |
pyproject.toml |
Registers the custom markers. |
requirements.txt |
pytest. |
.circleci/config.yml |
Runs the tests on CircleCI with circleci testsuite run. |
.circleci/test-suites.yml |
Defines the ci tests suite: how Smarter Testing finds and runs the test files. |
Requires Python 3.11 or later.
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
pytestRun only the slow test with pytest -m slow, or skip it with pytest -m "not slow".
Fork this repository, then set up your fork as a project in the CircleCI web app (Home > Create Project) or with circleci onboard from inside your clone. Each push runs the test job. Its Tests tab shows the results (filter by Node to see which tests each container ran), and its Timing tab shows how long each container took.