# CollectionError: cannot collect 'test_foo' because it is not a function or class

- **ID:** `python/pytest-collection-error`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

pytest 试图收集一个名为 test_foo 的变量或对象，而不是测试函数

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.4.0 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   my_foo = 123
   ```
2. **** (80% success)
   ```
   collect_ignore = ['test_foo']
   ```

## Dead Ends

- **** — 如果变量在模块级别，pytest 可能仍会尝试收集 (40% fail)
- **** — 只适用于类，不适用于变量 (70% fail)
