# ERROR collecting tests/test_models.py
  File "tests/test_models.py", line 3
    def test_model(:
                  ^
SyntaxError: invalid syntax

- **ID:** `python/pytest-collection-error-syntax-in-test`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A syntax error in a test module (or a module it imports) prevents pytest from collecting it. The error aborts collection for the whole file, so other tests in that file never run.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   python -m py_compile tests/test_models.py && pytest tests/test_models.py
   ```
2. **** (90% success)
   ```
   ruff check tests/ && pytest
   ```

## Dead Ends

- **** — Lets other files run but the broken file still contributes zero tests, silently reducing coverage. (80% fail)
- **** — The tests in that file are permanently skipped; the syntax error is never fixed. (75% fail)
