Skip to main content
Back to list
testingAdvanced8 часов 20 минут9 lessons

Pytest: Борьба с Race Conditions в Async-коде

ТОЛЬКО для async-разработчиков: race conditions, flaky tests, async fixtures — специализация для asyncio.

9 lessons 8 часов 20 минут
Pytest: Борьба с Race Conditions в Async-коде

What you'll learn

Специализированный курс ТОЛЬКО для async-разработчиков: pytest-asyncio, race conditions в PostgreSQL/Redis, flaky tests, resilience patterns. ВАЖНО: Если вы НЕ работаете с async/await ежедневно — этот курс не для вас. 8 часов глубокого погружения в async-тестирование.

⚠️ ONLY for async developers

This course is NOT for sync code. If you DON'T use async/await daily—take 'DB Testing' (Level 4) instead of this course.

Full cycle of flaky test handling

From diagnosis to production fix: reproduce race conditions, analyze causes, fix with proper patterns. Structured approach from simple to complex.

Practical learning cases

Simplified examples of typical production problems: promo codes twice, double charges, Redis failures. Enough to understand patterns, but not full production complexity.

Pure async, no compromises

Entire course — async code only. pytest-asyncio, asyncpg, aioredis. No sync examples. Deep dive into async testing.

Automated detection

Write your own pytest plugin for automatic flaky test detection, CI integration, quarantine of unstable tests, and quality gates.

Testimonials

alumni

Nondeterministic tests have two problems. First, they are useless. Second, they are a virulent infection that can completely ruin your entire test suite.

Martin Fowler

Tests should be deterministic. If they aren't, you can't trust them, and if you can't trust them, they're worthless.

Kent Beck (создатель TDD)

Flaky tests are one of the most harmful things that can happen to a test suite. They erode confidence and waste enormous amounts of engineering time.

Google Testing Blog

What's inside

Async fixtures for PostgreSQL and Redis: transactions, rollback, concurrent operations

Race conditions in learning cases: promo code twice, double charge, stale cache—reproduce and fix in simplified examples

Idempotency and locks: asyncio.Lock, Redis Lock, unique operation keys, retry logic testing

Resilience testing: graceful degradation, circuit breakers, health checks on service failures

Custom pytest plugin: automatic flaky test detection, CI integration, quality gates

Prerequisites

Pytest Basics: First Tests

required

Minimum Level 1 (basic tests). Recommended to complete levels 1-3 for deep understanding.

Go to course

Python async/await: practical experience

required

REQUIRED: minimum 4 hours of async/await, asyncio.gather, asyncio.Lock practice. Course will be incomprehensible without it. Recommended: 'Real Python: Async IO in Python' or asyncio official docs.

PostgreSQL: basic operations

Experience with PostgreSQL: SELECT, INSERT, UPDATE, transactions. Recommended for understanding DB examples.

FAQ

Do I need to take basic courses before this?

Minimum Level 1 (basic tests). Recommended to complete Levels 1-3 for confidence in fixtures, mocks, pytest-xdist. But main requirement—async/await experience: minimum 4 hours asyncio practice.

I don't work with async. Is this course for me?

NO. This course is ONLY about async testing. Without async/await experience, you won't understand the material. First complete minimum 4 hours of asyncio practice, then come back.

Is this course for me if I work with databases?

Only if you use asyncpg/aiohttp/async DB drivers. If working with psycopg2/requests (sync code)—take 'DB Testing' (Level 4). Same patterns but without async.

What should I do after the course?

Find a flaky test in your project (everyone has them!), reproduce the race, write a fix. Then: add async fixtures, set up observability, write your own pytest plugin for flaky detection.

#pytest#advanced#flaky-tests#race-conditions#asyncio#postgresql#redis#production
Pytest: Борьба с Race Conditions в Async-коде — Learning Center — Potapov.me