Patterns
Recurring designs and idioms.
- Arrange-Act-AssertA three-part structure for a test โ set up the situation, perform the one action being tested, then check the result.
- if __name__ == "__main__":Runs code only when a file is executed directly โ not when another module imports it.
- Mutable Default ArgumentA default argument value is created once, when the function is defined โ using a mutable object as one silently shares state across every call that relies on it.
- pytest.raises()Assert that a block of code raises a specific exception โ the standard way to test error handling itself, not just successful results.