MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_saved_content

Method test_saved_content

tests/transforms/test_save_image.py:47–62  ·  view source on GitHub ↗
(self, test_data, meta_data, output_ext, resample)

Source from the content-addressed store, hash-verified

45
46 @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])
47 def test_saved_content(self, test_data, meta_data, output_ext, resample):
48 if meta_data is not None:
49 test_data = MetaTensor(test_data, meta=meta_data)
50
51 with tempfile.TemporaryDirectory() as tempdir:
52 trans = SaveImage(
53 output_dir=tempdir,
54 output_ext=output_ext,
55 resample=resample,
56 separate_folder=False, # test saving into the same folder
57 output_name_formatter=lambda x, xform: dict(subject=x["filename_or_obj"] if x else "0"),
58 )
59 trans(test_data)
60
61 filepath = "testfile0" if meta_data is not None else "0"
62 self.assertTrue(os.path.exists(os.path.join(tempdir, filepath + "_trans" + output_ext)))
63
64 @parameterized.expand([TEST_CASE_5])
65 def test_saved_content_with_filename(self, test_data, output_ext, resample):

Callers

nothing calls this directly

Calls 2

MetaTensorClass · 0.90
SaveImageClass · 0.90

Tested by

no test coverage detected