# ERROR collecting tests/test_example.py
E   SyntaxError: invalid syntax

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

## Root Cause

There is a syntax error in the test file or an imported module, preventing pytest from collecting the test.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   python -m py_compile tests/test_example.py
Fix the reported syntax error, then rerun pytest.
   ```
2. **** (90% success)
   ```
   flake8 tests/test_example.py
Address the reported issues.
   ```

## Dead Ends

- **** — pytest cannot collect tests from a file with syntax errors; the test will not run. (95% fail)
- **** — This hides the underlying syntax error and may cause other tests to fail if the module is imported elsewhere. (80% fail)
