Skip to main content
Loading page…
Python Mastery
Chapter 25
Lesson 2 of 4
unittest & Mocking
Contents
Notes
Tutor
Concept
unittest: Python's Built-in Test Framework
Loading activity…
Previous
1 / 8
Continue
Contents
Notes
Discussion
Tutor
26 min
8 activities
0 of 8 done
In this lesson
1
unittest: Python's Built-in Test Framework
2
unittest Assertion Methods
3
Mocking: Replacing Real Dependencies
4
Mocking with patch: Real-World Example
5
monkeypatch: pytest's Fixture for Patching
6
Check: Where to Patch
7
Tip: Test Doubles Taxonomy
8
Practice: Test a File-Reading Function with a Mock
Objectives
Structure tests using unittest.TestCase with setUp and tearDown
Use the full range of unittest assertion methods
Replace real dependencies with mocks using unittest.mock.patch
Verify that mocked functions were called with the right arguments
Chapter 25 · Testing, Debugging & Performance
Testing with pytest
unittest & Mocking
Debugging Effectively
Profiling & Performance
Previous: Testing with pytest
Next: Debugging Effectively