Skip to content

Commit

Permalink
Reimplement cd_to_tempdir due to issues in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Argmaster committed Feb 8, 2025
1 parent 7f703df commit 29b11d8
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import json
import logging
import os
import shutil
from contextlib import contextmanager, suppress
from pathlib import Path
from tempfile import TemporaryDirectory
from tempfile import mkdtemp
from typing import Any, Generator

import pytest
Expand All @@ -23,13 +24,20 @@
@contextmanager
def cd_to_tempdir() -> Generator[Path, None, None]:
original_cwd = Path.cwd().as_posix()
with suppress( # noqa: SIM117
FileNotFoundError, NotADirectoryError, FileExistsError, PermissionError
temp_dir_path = Path(mkdtemp())

os.chdir(temp_dir_path.as_posix())
yield temp_dir_path
os.chdir(original_cwd)

with suppress(
FileNotFoundError,
NotADirectoryError,
FileExistsError,
PermissionError,
RecursionError,
):
with TemporaryDirectory() as tempdir:
os.chdir(tempdir)
yield Path(tempdir)
os.chdir(original_cwd)
shutil.rmtree(temp_dir_path.as_posix())


class AssetLoader:
Expand Down

0 comments on commit 29b11d8

Please sign in to comment.