# TypeError: test_foo() missing 1 required positional argument: 'mock_bar'

- **ID:** `python/unittest-mock-patch-decorator-order`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

When using multiple @patch decorators, the mocks are passed in bottom-up order. If the test function signature does not match, a TypeError occurs.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   @patch('module.ClassB')
@patch('module.ClassA')
def test_foo(mock_a, mock_b):  # mock_a corresponds to bottom decorator
    ...
   ```
2. **** (98% success)
   ```
   def test_foo():
    with patch('module.ClassA') as mock_a, \
         patch('module.ClassB') as mock_b:
        ...
   ```

## Dead Ends

- **** — This hides the error but makes the test less clear and may cause issues with assertions. (70% fail)
- **** — This may not be possible if multiple dependencies need mocking. (60% fail)
