From 92950eb61a27917243cba21850bccc8bb3e9a938 Mon Sep 17 00:00:00 2001 From: F-G Fernandez Date: Fri, 18 Oct 2019 12:17:32 +0200 Subject: [PATCH] test: Updated asserts in test_transforms_video Updated all raw asserts to corresponding unittest.TestCase.assert. See #1483 --- test/test_transforms_video.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_transforms_video.py b/test/test_transforms_video.py index 2bb72e9889f..296d519f5c4 100644 --- a/test/test_transforms_video.py +++ b/test/test_transforms_video.py @@ -25,8 +25,8 @@ def test_random_crop_video(self): transforms.ToTensorVideo(), transforms.RandomCropVideo((oheight, owidth)), ])(clip) - assert result.size(2) == oheight - assert result.size(3) == owidth + self.assertEqual(result.size(2), oheight) + self.assertEqual(result.size(3), owidth) transforms.RandomCropVideo((oheight, owidth)).__repr__() @@ -41,8 +41,8 @@ def test_random_resized_crop_video(self): transforms.ToTensorVideo(), transforms.RandomResizedCropVideo((oheight, owidth)), ])(clip) - assert result.size(2) == oheight - assert result.size(3) == owidth + self.assertEqual(result.size(2), oheight) + self.assertEqual(result.size(3), owidth) transforms.RandomResizedCropVideo((oheight, owidth)).__repr__() @@ -110,13 +110,13 @@ def samples_from_standard_normal(tensor): mean = [clip[c].mean().item() for c in range(channels)] std = [clip[c].std().item() for c in range(channels)] normalized = transforms.NormalizeVideo(mean, std)(clip) - assert samples_from_standard_normal(normalized) + self.assertTrue(samples_from_standard_normal(normalized)) random.setstate(random_state) # Checking the optional in-place behaviour tensor = torch.rand((3, 128, 16, 16)) tensor_inplace = transforms.NormalizeVideo((0.5, 0.5, 0.5), (0.5, 0.5, 0.5), inplace=True)(tensor) - assert torch.equal(tensor, tensor_inplace) + self.assertTrue(torch.equal(tensor, tensor_inplace)) transforms.NormalizeVideo((0.5, 0.5, 0.5), (0.5, 0.5, 0.5), inplace=True).__repr__() @@ -152,7 +152,7 @@ def test_random_horizontal_flip_video(self): p_value = stats.binom_test(num_horizontal, num_samples, p=0.5) random.setstate(random_state) - assert p_value > 0.0001 + self.assertGreater(p_value, 0.0001) num_samples = 250 num_horizontal = 0 @@ -163,7 +163,7 @@ def test_random_horizontal_flip_video(self): p_value = stats.binom_test(num_horizontal, num_samples, p=0.7) random.setstate(random_state) - assert p_value > 0.0001 + self.assertGreater(p_value, 0.0001) transforms.RandomHorizontalFlipVideo().__repr__()