See https://docs.pytest.org/en/stable/how-to/tmp_path.html and https://github.com/astropy/sphinx-automodapi/pull/182#discussion_r1574866190