Skip to content

About

Sample project for the CircleCI blog tutorial Pytest: Automated testing for Python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

pytest on CircleCI

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.

What's here

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.

Run it locally

Requires Python 3.11 or later.

python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
pytest

Run only the slow test with pytest -m slow, or skip it with pytest -m "not slow".

Run it on CircleCI

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.

About

Sample project for the CircleCI blog tutorial Pytest: Automated testing for Python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages