# FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pytest-of-root/pytest-12/test_write0/data.json'

- **ID:** `python/pytest-tmp-path-not-shared`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

`tmp_path` is function-scoped and unique per test; a file written in one test is not visible in another because each test gets a fresh numbered directory.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   Use `tmp_path_factory` for a session-scoped shared dir:
@pytest.fixture(scope='session')
def shared_data(tmp_path_factory):
    p = tmp_path_factory.mktemp('shared')
    (p / 'data.json').write_text('{}')
    return p
   ```
2. **** (85% success)
   ```
   Or pass the path explicitly from the producing test to the consumer via a fixture dependency chain.
   ```

## Dead Ends

- **** — Breaks isolation and parallel runs; tests collide and leave stale state. (85% fail)
- **** — Parent is the per-run root shared by all tests in the session; writing there risks collisions under xdist. (60% fail)
