Many applications need to write data to disk. Surely we don't want data written during tests to interfere with the data we read/write during the real program execution. Data fixtures used in tests usually have to be predictable and we certainly don't want to corrupt real data when we run our tests.
So it's common for a test suite to have its own read/write path where all the data is written. If we decided the path beforehand, by the way, there would be the risk that different test runs would read previous data and thus might not spot bugs or might fail without a reason.
For this reason, one of the fixtures that pytest provides out of the box is tmp_path, which, when injected into a test, provides a temporary path that is always different on every test run. Also, it will take care of retaining the most recent temporary directories (for debugging purposes) while deleting the oldest ones:
def test_tmp(tmp_path):
f = tmp_path / "...