How to use temporary directories and files in tests
https://docs.pytest.org/en/7.3.x/how-to/tmp_path.html
#pytest
pytestではPython tempfileを使う必要がない!
The tmp_path fixture
You can use the tmp_path fixture which will provide a temporary directory unique to the test invocation, created in the base temporary directory.
tmp_path is a pathlib.Path object.
The tmp_path_factory fixture
The tmpdir and tmpdir_factory fixtures
👉4.1 tmpdirとtmpdir_factoryを使用する
These days, it is preferred to use tmp_path and tmp_path_factory.
積ん読