Preamble

Good tests mirror the benchmark posts: one obvious behavior per case, shared setup factored out, failures that name what regressed. pytest fixtures and parametrization are how I encode context and variants without copy-paste.


Layout

Mirror tests/ to package names for larger projects; colocate test_*.py for small modules. Keep conftest.py free of accidental import side effects—fixtures should not boot databases just because pytest imported the tree.


Fixtures and parameters

import pytest

@pytest.fixture
def sample_graph():
    return {0: [1, 2], 1: [2], 2: []}

@pytest.mark.parametrize("start", [0, 1])
def test_reachable(sample_graph, start):
    assert start in sample_graph

Fixtures document preconditions; parametrize tables encode equivalence classes you would otherwise hand-copy.


Conclusion

Tests are executable documentation—they pay down debugging cost for algorithm and concurrency posts later. Maven Coordinates for Python Developers maps Maven to pip mental models for Java onboarding.