Skip to content

Commit

Permalink
test: Add platform check before 'unlink', skip windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lsetiawan committed Jan 23, 2024
1 parent 3ebeba7 commit 03aba11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions tests/sims/test_simulator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from pathlib import Path
import sys

import torch

Expand Down Expand Up @@ -64,5 +65,6 @@ def test_load_state_dict(self, simple_common_sim):
== simple_common_sim.z_s.value
)

# Cleanup
Path(fpath).unlink(missing_ok=True)
# Cleanup after only for non-windows
if not sys.platform.startswith("win"):
Path(fpath).unlink(missing_ok=True)
11 changes: 7 additions & 4 deletions tests/sims/test_state_dict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pathlib import Path
from tempfile import TemporaryDirectory
import os
import sys

import pytest
import torch
Expand Down Expand Up @@ -143,8 +144,9 @@ def test_save(self, simple_state_dict):
assert Path(default_fpath).exists()
assert default_fpath == str(expected_fpath.absolute())

# Cleanup after
Path(default_fpath).unlink(missing_ok=True)
# Cleanup after only for non-windows
if not sys.platform.startswith("win"):
Path(default_fpath).unlink(missing_ok=True)

# Check for specified save path
with TemporaryDirectory() as tempdir:
Expand All @@ -166,5 +168,6 @@ def test_load(self, simple_state_dict):
loaded_state_dict = StateDict.load(fpath)
assert loaded_state_dict == simple_state_dict

# Cleanup after
Path(fpath).unlink(missing_ok=True)
# Cleanup after only for non-windows
if not sys.platform.startswith("win"):
Path(fpath).unlink(missing_ok=True)

0 comments on commit 03aba11

Please sign in to comment.