diff --git a/python/test/regression/conftest.py b/python/test/regression/conftest.py index d88687b45f..23b32aacbd 100644 --- a/python/test/regression/conftest.py +++ b/python/test/regression/conftest.py @@ -14,9 +14,13 @@ def device(request): @pytest.fixture def fresh_triton_cache(): - with tempfile.TemporaryDirectory() as tmpdir: - try: - os.environ["TRITON_CACHE_DIR"] = tmpdir - yield tmpdir - finally: - os.environ.pop("TRITON_CACHE_DIR", None) + try: + with tempfile.TemporaryDirectory() as tmpdir: + try: + os.environ["TRITON_CACHE_DIR"] = tmpdir + yield tmpdir + finally: + os.environ.pop("TRITON_CACHE_DIR", None) + except OSError: + # Ignore errors, such as PermissionError, on Windows + pass diff --git a/python/test/unit/conftest.py b/python/test/unit/conftest.py index d88687b45f..23b32aacbd 100644 --- a/python/test/unit/conftest.py +++ b/python/test/unit/conftest.py @@ -14,9 +14,13 @@ def device(request): @pytest.fixture def fresh_triton_cache(): - with tempfile.TemporaryDirectory() as tmpdir: - try: - os.environ["TRITON_CACHE_DIR"] = tmpdir - yield tmpdir - finally: - os.environ.pop("TRITON_CACHE_DIR", None) + try: + with tempfile.TemporaryDirectory() as tmpdir: + try: + os.environ["TRITON_CACHE_DIR"] = tmpdir + yield tmpdir + finally: + os.environ.pop("TRITON_CACHE_DIR", None) + except OSError: + # Ignore errors, such as PermissionError, on Windows + pass