# AttributeError: type object 'TestDb' has no attribute 'client'
  File "tests/test_db.py", line 22, in test_query
    resp = self.client.get('/health')

- **ID:** `python/unittest-setupclass-attribute-error`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

`setUpClass` is a classmethod; assigning `self.client` inside it sets an instance attribute on the class object, not on instances, so `self.client` on a test instance is missing.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Assign on the class explicitly:
@classmethod
def setUpClass(cls):
    cls.client = TestClient(app)
    cls._server = start_server()
   ```
2. **** (88% success)
   ```
   Or use a class-scoped pytest fixture instead:
@pytest.fixture(scope='class')
def client():
    return TestClient(app)
   ```

## Dead Ends

- **** — The attribute exists but is None; calling `.get` raises AttributeError on NoneType. (80% fail)
- **** — Works but recreates the client for every test, defeating the purpose of setUpClass and slowing the suite. (50% fail)
