# FAILED tests/test_x.py::TestX::test_y - subtest failed
# but exit code is 0 and CI passes

- **ID:** `python/pytest-subtests-failure-not-counted`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

unittest subTest failures are reported but pytest's exit code may remain 0 if the test method itself doesn't propagate the failure, especially in older pytest or with plugins that swallow subtest outcomes.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   pip install -U pytest
# pytest >= 7.2 correctly reports subtest failures in exit code
   ```
2. **** (85% success)
   ```
   def test_y(self):
    errors = []
    for case in cases:
        with self.subTest(case=case):
            try:
                check(case)
            except AssertionError as e:
                errors.append(e)
    if errors:
        raise AssertionError(errors)
   ```

## Dead Ends

- **** — Stops on first failure but doesn't change exit code semantics for subtest failures. (85% fail)
- **** — Changes traceback style, not exit code behavior. (95% fail)
- **** — Loses the per-subtest granularity that subTest was meant to provide. (70% fail)
