Pytest для джунов: Моки и интеграция
Моки для HTTP/файлов, coverage, pytest.ini, conftest.py — от учебных тестов к реальным задачам.

What you'll learn
Переход от базовых тестов к реальным задачам: мокирование HTTP/файлов/времени, coverage для контроля качества, pytest.ini конфигурация, conftest.py. Мини-проект с кешем и API — не игрушечные примеры.
Mocking without pain
unittest.mock, patch, requests-mock—learn to test code with HTTP, files, time without real dependencies.
Coverage for quality control
pytest-cov: setup, reading metrics, IDE integration. Find uncovered code and test gaps.
Configuration for teams
pytest.ini and conftest.py: project settings, fixture reuse, markers for entire team.
Real mini-project
Todo app with cache, HTTP API, and failure handling. Bringing all skills together.
Testimonials
alumni“The only way to go fast is to go well. And the only way to go well is to have tests.”
Robert C. Martin (Uncle Bob)
“Mocks aren't stubs. Use mocks to verify interactions, stubs to provide canned answers.”
Martin Fowler
What's inside
unittest.mock: Mock, patch, MagicMock for mocking dependencies
HTTP mocks: requests-mock or responses for testing API clients
Time mocking: freezegun for tests with dates and timers
File mocking: unittest.mock for file I/O without real files
Coverage: pytest-cov setup, pytest --cov, reading metrics, HTML reports
pytest.ini: marker configuration, testpaths, addopts for team
conftest.py: fixture reuse, plugins, hooks
Mini-project: Todo with cache and API from first test to integration
Prerequisites
Pytest Basics: First Tests
requiredBasic course is mandatory. You must know: assert, simple fixtures, parametrization, markers.
Go to courseCourse curriculum
🎭 Мокирование: Зачем и когда
15 минут
🔧 unittest.mock: Mock, patch, MagicMock
25 минут
🌐 Мокирование HTTP: requests-mock
25 минут
⏰ Мокирование времени и файлов
25 минут
📊 Coverage: Контроль качества тестов
25 минут
⚙️ pytest.ini: Конфигурация для команды
20 минут
📦 conftest.py: Переиспользование фикстур
20 минут
🏆 Мини-проект: Todo с кешем и API
30 минут
FAQ
Is basic course needed before this?
YES, mandatory. This course assumes you know assert, fixtures, parametrization from basic course (Level 1). Without it will be difficult.
How is it different from basic course?
Basic course—simple tests (assert, fixtures). This course—real tasks: mocking HTTP, coverage, team configuration. Transition from educational examples to practice.
What's next after this course?
Next step—'Pytest: Professional Tools' (Level 3): pytest-xdist for speedup, src layout, advanced fixtures, plugins. Production-ready skills.
Why is it free?
Levels 1-2 are free forever—my way to help juniors. Premium courses start from Level 4 (DB testing). The sooner you take it, the faster growth.
Related Materials
These materials complement the course but are not part of it. Study at your own pace.