Skip to content

Commit

Permalink
fix: handle tmp file deletion manually
Browse files Browse the repository at this point in the history
  • Loading branch information
keithmanville committed Jan 31, 2025
1 parent a313bf2 commit 16d3401
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/unit/restapi/v1/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,16 +737,15 @@ def registered_mlflowrun_incomplete(
def resources_tar_file() -> DioptraFile:
os.chdir(Path(__file__).absolute().parent / "resource_import_files")

f = NamedTemporaryFile(suffix=".tar.gz")
with tarfile.open(fileobj=f, mode="w:gz") as tar:
tar.add("dioptra.toml")
tar.add("plugins", recursive=True)
tar.add(Path("examples", "hello-world.yaml"))
f.seek(0)
with NamedTemporaryFile(suffix=".tar.gz", delete=False) as f:
with tarfile.open(fileobj=f, mode="w:gz") as tar:
tar.add("dioptra.toml")
tar.add("plugins", recursive=True)
tar.add(Path("examples", "hello-world.yaml"))

yield select_one_or_more_files([f.name])[0]

f.close()
os.unlink(f.name)


@pytest.fixture
Expand Down

0 comments on commit 16d3401

Please sign in to comment.