Pytest Fixtures

Fixtures in pytest are functions that provide a fixed baseline for tests, allowing resources (like database connections, input data, etc.) to be accessed and reused across multiple test cases. They can also handle setup and teardown for each test. Upon test initialization, fixtures are executed, and their results cached to be used and reused. The persistence of this cache depends on a specified “scope”. In this note, my intention is to jot down important concepts about fixtures and show some common ways in which they’re used.

Read More

Pytest Markers & Parametrization

Pytest markers are like tags. Tag your tests to keep them organized. Use markers to indicate test priority, or group them by performance, integration, or acceptance. Use them to skip tests under certain conditions, or mark them as expected failures. Use parametrization to run your test under different parameters.

Read More

Pyproject.toml Template

If you don’t already have a pyproject.toml file for your existing project, you should. It is required to use with pip install . and with poetry. Let’s take a look at what a pyproject file looks like.

Read More