import pytest @pytest.fixture def tmp_file_path(request, tmpdir): if request.param: path = str(tmpdir) + "/" + str(request.param) with open(path, "w+", encoding="utf-8") as f: f.write("test") return path