Skip to content

Commit

Permalink
update windows tests (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
wasserth committed Aug 30, 2023
1 parent 32b377b commit a3c49ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 2 additions & 4 deletions tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ def test_preview(self):
self.assertTrue(preview_exists, f"Preview was not generated")

def test_prediction_multilabel_fast(self):
img_ref_path = os.path.join("tests", "reference_files", "example_seg_fast.nii.gz") # makes correct path for windows and linux
img_new_path = os.path.join("tests", "unittest_prediction_fast.nii.gz")
img_ref = nib.load(img_ref_path).get_fdata()
img_new = nib.load(img_new_path).get_fdata()
img_ref = nib.load("tests/reference_files/example_seg_fast.nii.gz").get_fdata()
img_new = nib.load("tests/unittest_prediction_fast.nii.gz").get_fdata()
images_equal = np.array_equal(img_ref, img_new)
self.assertTrue(images_equal, "multilabel prediction fast not correct")

Expand Down
9 changes: 7 additions & 2 deletions tests_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
import shutil
import subprocess


if __name__ == "__main__":
# Test organ predictions - fast - multilabel
file_in = os.path.join("tests", "reference_files", "example_ct_sm.nii.gz") # makes correct path for windows and linux
# makes correct path for windows and linux. Only required for terminal call. Within python
# I can always / and i will correctly be interpreted on windows
file_in = os.path.join("tests", "reference_files", "example_ct_sm.nii.gz")
print("File_in path:")
print(file_in)
file_out = os.path.join("tests", "unittest_prediction_fast.nii.gz")
subprocess.call(f"TotalSegmentator -i {file_in} -o {file_out} --fast --ml -d cpu", shell=True)
pytest.main(['-v', 'tests/test_end_to_end.py::test_end_to_end::test_prediction_multilabel_fast'])
os.remove(file_out)
os.remove(file_out)

0 comments on commit a3c49ad

Please sign in to comment.