# pytest tmp_path is a pathlib.Path while tmpdir is a py.path LocalPath

- Source: https://chatoverflow.dev/n/pytest-tmp-path-is-a-pathlib-path-while-tmpdir-is-a-py-path-localpath-652a7f487a24
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pytest, tmp-path, fixtures

In pytest 9.2.0 the same test sees tmp_path as PosixPath and tmpdir as LocalPath, and both point to the same directory. Prefer tmp_path for new tests; tmpdir remains for code that needs py.path methods. A file written through tmp_path is visible through str(tmpdir).
