
Skillama course
Python Testing
Master Python testing from basics to automation.
Overview
This course provides a comprehensive introduction to Python testing, starting from fundamentals and progressing through advanced practices. Learners will explore both unittest and pytest frameworks, dive into asynchronous and concurrent testing, and learn how to apply static analysis and type safety in tests. The curriculum emphasizes practical application through real-world projects and mini-projects such as ATM system testing and REST API automation. By the end, students will have built a complete test suite and gained experience in CI/CD, packaging, and quality engineering best practices.
Objectives
- Understand core testing concepts and Python's internal test execution model.
- Build and organize test suites using unittest and pytest frameworks with advanced features like fixtures and parametrization.
Key topics
- Testing Fundamentals and Python Test Internals
- unittest Framework and Object-Oriented Testing
- Decorators, Fixtures, and Context Managers
- Async Testing with asyncio and aiohttp
Expected outcomes
- Create robust, maintainable test suites that cover unit, integration, and async code using modern Python testing tools.
- Apply performance optimization techniques and design patterns to improve test reliability and efficiency.
How the AI Tutor can help
How the Skillama AI Tutor helps with the listed lectures: explanations, follow-up questions, and running or debugging practice code.
Who this is for
This course is for developers and QA professionals looking to master Python testing with hands-on practice and real-world applications.
Curriculum
1. Testing Fundamentals & Python Test Internals
- What is software testing & why it matters
- Python test execution model & bytecode awareness
- Types of testing: Unit, Integration, E2E, Regression
- Test lifecycle: setup, execution, teardown
- Object identity vs equality in assertions
- Test isolation principles
- Testing best practices & anti-patterns
- Inspect how Python runs a test file with dis module
- Trace test execution flow with logging
- Compare assertEqual vs assertIs in real scenarios
- Visualize test lifecycle with a custom runner
2. unittest Framework & OOP-Based Testing
- TestCase class & MRO in test hierarchies
- setUp, tearDown, setUpClass, tearDownClass
- Custom assertions & test descriptors
- Abstract test base classes (ABC)
- Test class decorators (@skip, @skipIf)
- Data-driven tests with subTest()
- Build a reusable base TestCase with custom assertions
- Create an auto-registering test suite using metaclass
- Implement a validated test data class
- Explore MRO in complex test hierarchies
3. Decorators, Fixtures & Context Managers
- pytest fixture functions & scopes
- Fixture factories & parametrized fixtures
- conftest.py & fixture sharing
- Context managers for test resources
- @pytest.mark decorators
- __enter__ / __exit__ in test setup
- Async fixtures & context managers
- Build a retry fixture with exponential backoff
- Create a timing/logging fixture decorator
- Write a DB transaction context manager for tests
- Implement @singledispatch in test utilities
4. Test Generators, Parametrize & Functional Testing
- Iterator protocol in test data generation
- Generator-based test data factories
- pytest.mark.parametrize deep-dive
- Generator expressions for test cases
- itertools for combinatorial test inputs
- functools.lru_cache in test helpers
- Lazy test data evaluation patterns
- Build infinite test data sequence generators
- Implement a data pipeline test with generators
- Replace nested parametrize loops with itertools
- Memoize expensive test fixtures with lru_cache
5. Concurrent & Parallel Testing
- GIL impact on concurrent test execution
- pytest-xdist for parallel test runs
- Thread-safe test fixtures & locks
- Testing multithreaded code: race conditions
- Multiprocessing test isolation
- Deadlock detection in tests
- concurrent.futures in test helpers
- Benchmark serial vs parallel test execution
- Build a concurrent test file runner
- Test thread-safety of a shared resource
- Detect & reproduce a deadlock in test suite
6. Async Testing (asyncio & aiohttp)
- Testing async functions with pytest-asyncio
- async / await in test functions
- Testing Coroutines, Tasks & Futures
- asyncio.gather in test scenarios
- Async test generators & parametrize
- Mocking aiohttp async HTTP calls
- Async fixtures & context managers
- Testing mixed sync/async codebases
- Write async tests for a web scraper
- Test a real-time chat server with asyncio
- Mock 100 concurrent API calls in tests
- Migrate sync test suite to async
7. Type-Safe Testing & Static Analysis
- Type annotations in test functions (PEP 484)
- Typed test fixtures: List, Dict, Optional
- TypeVar & Generic test helpers
- Runtime validation testing with Pydantic
- Running mypy on test files
- Pyright for test code analysis
- Typed test data classes & factories
- Annotate a full test module and run mypy
- Build a typed test client with Pydantic models
- Define a Protocol-based test interface
- Refactor untyped tests with type hints
8. Advanced Testing & Quality Engineering
- pytest: advanced fixtures, parametrize, markers
- patch & MagicMock (unittest.mock)
- Property-based testing with Hypothesis
- Test coverage with pytest-cov
- Mutation testing with mutmut
- Performance testing with pytest-benchmark
- TDD workflow: Red-Green-Refactor
- Write parametrized tests for a data parser
- Mock external API calls with MagicMock
- Generate 1000 edge cases with Hypothesis
- Achieve 90%+ coverage on a module
9. Test Performance & Profiling
- Profiling slow tests: cProfile, line_profiler
- Memory profiling in tests: memory_profiler
- Benchmarking with pytest-benchmark & timeit
- Optimizing test data with numpy
- Speeding up test helpers with Cython
- JIT-accelerating test simulations with Numba
- Big-O analysis of test complexity
- Profile a slow test suite and optimize by 10x
- Replace pure Python test data loop with numpy
- Compile a test helper with Cython
- JIT-accelerate a load simulation with Numba
10. Test Packaging, CI/CD & Project Management
- pyproject.toml for test configuration
- pytest.ini vs setup.cfg vs pyproject.toml
- Semantic versioning for test libraries
- Virtual environments for isolated test runs
- uv for fast test dependency resolution
- Publishing test utilities to PyPI
- Private test package registries
- Package a test utility library with Poetry
- Publish a test helper to TestPyPI
- Create a reproducible test environment with uv
- Write a GitHub Actions test release workflow
11. Test Design Patterns
- Creational: Test Factory, Builder, Object Mother
- Structural: Test Adapter, Decorator, Proxy
- Behavioral: Test Observer, Strategy, Command
- Pythonic test patterns (Page Object, AAA)
- Dependency Injection in test setup
- Event-driven test architecture
- Implement Page Object pattern for UI tests
- Build a test data factory with Factory pattern
- Refactor messy tests using Strategy pattern
- Design a DI container for test dependencies
12. Capstone Testing Project
- Track A — End-to-End Test Suite for Data Pipeline
- Track B — CLI Tool Testing with pytest + rich
- Track C — REST API Test Automation (FastAPI + Pydantic)
- Track D — Plugin Framework Testing (metaclasses + DI)
- Code review & test optimization
- Test documentation & reporting
- Build a complete test suite end-to-end
- Profile & optimize slow test paths
- Write unit + integration tests (≥80% coverage
- Package and publish test suite to TestPyPI
- Peer test code review session
- Present test architecture decisions
13. Mini Project
- ATM System Testing
- PIN Validation Testing
- Balance Inquiry Testing
- Cash Withdrawal Testing
- Deposit Testing
AI Tutor · Code Execution · Debugger · Study Materials. All in one platform.