# AttributeError: 'TestCaseFunction' object has no attribute 'subTest'

- **ID:** `python/pytest-subtests-plugin-missing`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

self.subTest() is a unittest.TestCase method. Calling it on a pytest-style test class or a plain function that doesn't inherit from unittest.TestCase raises AttributeError.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   import unittest
import pytest

class TestMath(unittest.TestCase):
    def test_add(self):
        for a, b, exp in [(1,2,3),(2,3,5)]:
            with self.subTest(a=a, b=b):
                self.assertEqual(a+b, exp)
   ```
2. **** (94% success)
   ```
   @pytest.mark.parametrize('a,b,exp', [(1,2,3),(2,3,5)])
def test_add(a, b, exp):
    assert a + b == exp
   ```

## Dead Ends

- **** — pytest-subtests adds support for TestCase.subTest in pytest-style classes only if the class inherits TestCase; a plain class still lacks the method. (70% fail)
- **** — Fragile; the semantics of subTest (reporting multiple failures per test) aren't replicated by a naive patch. (80% fail)
