Skip to content

Commit

Permalink
Fixed four test issues within test code. (#7662)
Browse files Browse the repository at this point in the history
### Description

This PR fixed the three issues within the test code that could cause
problems during CICD.

Three issues:

tests/test_pad_collation.py line 120: supposed to be assertEqual, but
not assertTure? or it will always be true.
tests/test_to_numpy.py line 74: Same as above.
tests/test_auto3dseg.py line 370: typo? two same asserts next to each
other.
tests/test_compose.py line 719, 725, 727: Should be assertEqual instead
of assertTrue

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Han Wang <[email protected]>
Co-authored-by: YunLiu <[email protected]>
  • Loading branch information
freddiewanah and KumoLiu authored Apr 19, 2024
1 parent ffd4454 commit 224c47a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion tests/test_auto3dseg.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ def test_filename_case_analyzer(self):
for batch_data in self.dataset:
d = transform(batch_data[0])
assert DataStatsKeys.BY_CASE_IMAGE_PATH in d
assert DataStatsKeys.BY_CASE_IMAGE_PATH in d

def test_filename_case_analyzer_image_only(self):
analyzer_image = FilenameStats("image", DataStatsKeys.BY_CASE_IMAGE_PATH)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,15 +716,15 @@ def test_compose_execute_equivalence_with_flags(self, flags, data, pipeline):
for k in actual.keys():
self.assertEqual(expected[k], actual[k])
else:
self.assertTrue(expected, actual)
self.assertEqual(expected, actual)

p = deepcopy(pipeline)
actual = execute_compose(execute_compose(data, p, start=0, end=cutoff, **flags), p, start=cutoff, **flags)
if isinstance(actual, dict):
for k in actual.keys():
self.assertTrue(expected[k], actual[k])
self.assertEqual(expected[k], actual[k])
else:
self.assertTrue(expected, actual)
self.assertEqual(expected, actual)


class TestComposeCallableInput(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pad_collation.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_pad_collation(self, t_type, collate_method, transform):
batch_inverse = BatchInverseTransform(dataset.transform, loader)
for data in loader:
output = batch_inverse(data)
self.assertTrue(output[0]["image"].shape, (1, 10, 9))
self.assertEqual(output[0]["image"].shape, (1, 10, 9))


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion tests/test_to_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_list_tuple(self):
assert_allclose(result, np.asarray(test_data), type_test=False)
test_data = ((1, 2), (3, 4))
result = ToNumpy(wrap_sequence=False)(test_data)
self.assertTrue(type(result), tuple)
self.assertIsInstance(result, tuple)
assert_allclose(result, ((np.asarray(1), np.asarray(2)), (np.asarray(3), np.asarray(4))))

def test_single_value(self):
Expand Down

0 comments on commit 224c47a

Please sign in to comment.