I always stumble on py.path methods.
A new pytest supports tmp_path fixture https://docs.pytest.org/en/latest/tmpdir.html#the-tmp-path-factory-fixture to work with pathlib.Path.
The issue is easy and waits for a champion.