# TypeError: 'TestSuite' object is not iterable

- **ID:** `python/unittest-testcase-not-iterable`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Code tries to iterate over a unittest.TestSuite directly (e.g. for t in suite), but TestSuite is not iterable in the way expected; tests must be accessed via suite._tests or by using a TestLoader/TextTestRunner.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   Use the loader to discover tests and iterate the returned suite's _tests, or use unittest's runner:

loader = unittest.TestLoader()
suite = loader.discover('tests')
result = unittest.TextTestRunner(verbosity=2).run(suite)
   ```
2. **** (80% success)
   ```
   Access the internal list when needed (with care):

for test in suite._tests:
    print(test)
   ```

## Dead Ends

- **** — TestSuite does not implement __iter__, so list() raises the same TypeError. (90% fail)
- **** — run() executes tests and returns a TestResult, not an iterable of tests. (85% fail)
