Runnable code examples for Python testing, pytest, FastAPI, and AI engineering articles on istranin.dev.
Browse examples · Getting started · Articles · Courses
Each directory is a self-contained project with its own dependencies, pyproject.toml, and uv.lock.
Read the corresponding article for the explanation, then use its example to run and explore the code.
| Example | Topics | Article |
|---|---|---|
| Pytest fixtures and mocking for AI agents | Scripted models, OpenAI and Anthropic adapters, HTTP mocks, offline CI | Read ↗ |
| Your first pytest test | Given-When-Then, plain assertions, failure reports, boundaries | Read ↗ |
| Python unit testing best practices | Behavior, parametrization, explicit fixtures, autospecced collaborators | Read ↗ |
| GitHub Actions Python testing | Python matrix, coverage, JUnit reports, stable merge check | Read ↗ |
| FastAPI testing with pytest | API testing, TestClient, validation, boundary cases |
Read ↗ |
| Behavior-driven development in Python with pytest-bdd | Shared examples, Gherkin, scenario outlines, reservation outcomes, TDD integration | Read ↗ |
| LangGraph agent testing with pytest | Agent graphs, tool calls, pytest-mock, failure paths | Read ↗ |
| Pytest hooks examples | CLI options, markers, collection, hook wrappers, terminal reports | Read ↗ |
| Pytest mocking tutorial | mocker, class and method patches, mock drift, lookup targets, decorators |
Read ↗ |
| Pytest fixtures and parametrization | Fixture architecture, factories, indirect setup, dynamic cases, scope costs, parallel workers | Read ↗ |
| Test-driven development in Python with pytest | Red-green-refactor, exceptions, parametrization, state boundaries | Read ↗ |
| Unit testing vs integration testing vs E2E in Python | Test boundaries, real configuration, subprocess CLI tests, regression and acceptance | Read ↗ |
Open an example directory and follow its README to install the locked dependencies and run the code.
You need Python 3.13 or newer and uv. Clone the repository and choose an example. For instance, to run the FastAPI tests:
git clone https://github.com/artem-istranin/istranin-dev-code-examples.git
cd istranin-dev-code-examples/fastapi-testing-pytest
uv sync --locked
uv run pytest test_main.py -vRun commands inside the example directory. Each example keeps its own environment and locked dependencies; the repository root is a catalog. The example README includes its expected results and any additional commands or exercises.
Keep each example focused on its companion article and independently runnable. Follow the same README structure used throughout this repository:
- The istranin.dev wordmark, example title, and a direct link to the companion article.
- Overview — the example's purpose and scope.
- Requirements — Python, uv, and any example-specific prerequisites.
- Run the example — commands and expected results.
- Project files — a map of the relevant source, tests, and dependency files.
- Any article-specific walkthroughs, experiments, or sources, followed by the shared navigation footer.
Preserve each article's teaching content, include its pyproject.toml and uv.lock, and add the
example and article links to the catalog above.
Created by Artem Istranin. Find the full articles and practical courses on istranin.dev.
This repository is licensed under the Apache License 2.0.