Pytest: Production-grade интеграционные тесты
Миграции БД, фабрики данных, Testcontainers, production REST API тестирование, параллельный запуск в CI — от учебных тестов к production.

What you'll learn
Выводите интеграционные тесты на production-уровень: Alembic миграции, factory_boy, Testcontainers, настоящие REST API тесты, глубокий CI/CD. 6+ часов практики с production-паттернами.
Starting from scratch: Docker and PostgreSQL in 40 minutes
Mandatory free module 0: install Docker, start PostgreSQL, first SELECT. No prerequisites—teaching everything needed for course.
DB migrations in tests: proper Alembic integration
Integrate Alembic into pytest fixtures. Apply migrations automatically before tests. Test on actual DB schema. Patterns for production projects with evolving schema.
Data factories: from manual hell to automation
Use factory_boy and faker for test data generation. Create complex scenarios with FK and dependencies. Eliminate copy-paste. Reusable factories for all tests.
Real integration API tests with Testcontainers
Start service in Docker via Testcontainers. Test over real HTTP network. Verify timeouts, connection errors, retry logic. Like in production, not in same process.
Production CI/CD: parallel execution and quality gates
Configure pytest-xdist for parallel tests in CI. Cache Docker images. Matrix strategy for different PostgreSQL versions. Coverage thresholds and quality gates.
Testimonials
alumni“The key to effective testing is to write tests at the right level. Integration tests give you confidence that your system works as a whole.”
Martin Fowler
“I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence.”
Kent Beck
“To me, legacy code is simply code without tests. Code without tests is bad code. It doesn't matter how well written it is.”
Michael Feathers (Working Effectively with Legacy Code)
What's inside
MODULE 0 (FREE): Docker Desktop installation, PostgreSQL in docker-compose.yml, psql connection, first SELECT, transactions—all in 40 minutes
Integration vs Unit: testing boundaries, pyramid, test doubles, when mocks hurt
Alembic + pytest: automatic migration application, session/module scope fixtures, testing on actual DB schema
factory_boy + faker: creating model factories, dependent factories (FK), realistic data generation, reuse in tests
PostgreSQL advanced: connection pooling, constraints/FK testing, isolation via transactions, TRUNCATE vs DELETE strategies
Testcontainers: running API service in Docker, container lifecycle management, testing over real network
REST API production tests: timeouts, connection errors, retry logic, negative scenarios, contract testing
Advanced fixtures: fixture factories, indirect parametrization, scope strategies for different resources, request object patterns
Production CI/CD: pytest-xdist parallel execution, Docker image caching, PostgreSQL version matrix strategy, coverage thresholds
Prerequisites
Pytest: Professional Tools
requiredLevel 3 course is mandatory. You must know: fixtures, mocks, markers, coverage, pytest-xdist, src layout.
Go to courseCourse curriculum
🐳 МОДУЛЬ 0: Docker и PostgreSQL — Quick Start
40 минут
Integration vs Unit: границы тестирования
35 минут
PostgreSQL + Alembic: миграции в тестах
50 минут
Фабрики данных: factory_boy + faker
55 минут
PostgreSQL: продвинутые сценарии
50 минут
REST API: тестирование с Testcontainers
55 минут
API + БД: сквозные production-сценарии
50 минут
Advanced fixtures: production-паттерны
55 минут
Production CI/CD: параллельный запуск и quality gates
60 минут
FAQ
How is it different from the basic course?
Levels 1-3—unit tests, mocks, professional tools. This course (Level 4)—production-grade integration tests with real infrastructure dependencies: PostgreSQL, Alembic migrations, factory_boy, Testcontainers, deep CI/CD. Transition to specialization.
Is Docker and PostgreSQL experience required?
NO! We start with mandatory FREE module 0 (40 minutes): install Docker, start PostgreSQL, first SELECT, understand transactions. No prerequisites—teaching everything from scratch.
Is async/await experience required?
NO. Entire course uses sync code: psycopg2 (not asyncpg), requests (not aiohttp). Async is a separate advanced course for those working with async/await.
What's next after this course?
Two paths: 1) 'Pytest Async'—race conditions, flaky tests (if your project is async). 2) 'Pytest in Production'—TDD, legacy, advanced CI/CD processes (for everyone). Both courses deepen skills from this course.
Why factory_boy instead of manual data creation?
In production projects, manual test data creation becomes copy-paste hell and brittle tests. factory_boy is industry standard for Python. You'll learn pattern used in real projects.
Related Materials
These materials complement the course but are not part of it. Study at your own pace.
Pytest: Fighting Race Conditions in Async Code
If your project uses async/await: async fixtures, race conditions, flaky tests. Apply patterns from this course (factory_boy, Testcontainers) to async code. ONLY for async developers.
Pytest: Legacy Code and TDD
Next step: covering legacy code with tests and adding new features via TDD. Characterization tests, seams, strangler fig, red-green-refactor.
Pytest: Contracts and Production CI/CD
Production readiness: contract testing for API, GitHub Actions with parallel execution, quality gates, flaky detection.