# ERROR collecting tests/test_math.py
  File "tests/test_math.py", line 7
    assert add(1, 2) == 3
                       ^
SyntaxError: invalid syntax

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

## Root Cause

A syntax error in the test file prevents pytest from importing it during collection, so the entire module is reported as an error rather than running any tests.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   python -m py_compile tests/test_math.py
   ```
2. **** (92% success)
   ```
   # .pre-commit-config.yaml
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: check-ast
   ```

## Dead Ends

- **** — Skips the broken module but hides the syntax error and leaves the test suite silently incomplete. (70% fail)
- **** — SyntaxError is raised at parse time, before any import statement executes, so the try/except never runs. (85% fail)
