From 64f8b153ee3f0c2035c84db21635390f6c396a42 Mon Sep 17 00:00:00 2001 From: Jeff Zhang Date: Tue, 21 Jul 2020 16:13:50 -0400 Subject: [PATCH] Remove if __name__ == __main__ from test code --- test/functional_cpu_test.py | 4 ---- test/test_batch_consistency.py | 4 ---- test/test_compliance_kaldi.py | 4 ---- test/test_dataloader.py | 4 ---- test/test_datasets.py | 4 ---- test/test_io.py | 3 --- test/test_kaldi_io.py | 4 ---- test/test_librosa_compatibility.py | 4 ---- test/test_sox_compatibility.py | 4 ---- test/test_sox_effects.py | 4 ---- test/test_transforms.py | 4 ---- 11 files changed, 43 deletions(-) diff --git a/test/functional_cpu_test.py b/test/functional_cpu_test.py index 7b531932e8..b162df2ebc 100644 --- a/test/functional_cpu_test.py +++ b/test/functional_cpu_test.py @@ -405,7 +405,3 @@ def test_mask_along_axis_iid(mask_param, mask_value, axis): assert mask_specgrams.size() == specgrams.size() assert (num_masked_columns < mask_param).sum() == num_masked_columns.numel() - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_batch_consistency.py b/test/test_batch_consistency.py index 03352ad2b0..e7040fdc0b 100644 --- a/test/test_batch_consistency.py +++ b/test/test_batch_consistency.py @@ -288,7 +288,3 @@ def test_batch_Vol(self): # Batch then transform computed = torchaudio.transforms.Vol(gain=1.1)(waveform.repeat(3, 1, 1)) self.assertEqual(computed, expected) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_compliance_kaldi.py b/test/test_compliance_kaldi.py index d58e5f9159..450183d6b3 100644 --- a/test/test_compliance_kaldi.py +++ b/test/test_compliance_kaldi.py @@ -246,7 +246,3 @@ def test_resample_waveform_multi_channel(self): single_channel_sampled = kaldi.resample_waveform(single_channel, self.test1_signal_sr, self.test1_signal_sr // 2) torch.testing.assert_allclose(multi_sound_sampled[i, :], single_channel_sampled[0], rtol=1e-4, atol=1e-7) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_dataloader.py b/test/test_dataloader.py index 1bf73ebb64..6d1518b70c 100644 --- a/test/test_dataloader.py +++ b/test/test_dataloader.py @@ -37,7 +37,3 @@ def test_1(self): dl = DataLoader(ds, batch_size=2) for x in dl: self.assertTrue(x.size() == expected_size) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_datasets.py b/test/test_datasets.py index 796df923b9..c77aa4917e 100644 --- a/test/test_datasets.py +++ b/test/test_datasets.py @@ -171,7 +171,3 @@ def test_libritts(self): assert original_text == self.original_text assert normalized_text == self.normalized_text assert utterance_id == f'{"_".join(str(u) for u in expected_ids[-4:])}' - - -if __name__ == "__main__": - unittest.main() diff --git a/test/test_io.py b/test/test_io.py index 2c8aece85e..b55885059a 100644 --- a/test/test_io.py +++ b/test/test_io.py @@ -282,6 +282,3 @@ def _test_5_get_info(self): self.assertEqual(si.length, samples) self.assertEqual(si.rate, rate) self.assertEqual(ei.bits_per_sample, precision) - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_kaldi_io.py b/test/test_kaldi_io.py index 4bd0fd56a4..80e6b3dc5a 100644 --- a/test/test_kaldi_io.py +++ b/test/test_kaldi_io.py @@ -33,7 +33,3 @@ def test_read_vec_flt_ark(self): def test_read_mat_ark(self): self._test_helper("mat.ark", [self.data1, self.data2], kio.read_mat_ark, torch.float32) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_librosa_compatibility.py b/test/test_librosa_compatibility.py index aa933535e8..c2ce3ec51d 100644 --- a/test/test_librosa_compatibility.py +++ b/test/test_librosa_compatibility.py @@ -347,7 +347,3 @@ def test_InverseMelScale(self): # torch.dist(spec_lr, spec_ta, p=1) # >>> tensor(943.2759) assert torch.dist(spec_orig, spec_ta, p=1) < threshold - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_sox_compatibility.py b/test/test_sox_compatibility.py index c63058b043..a6b59c4014 100644 --- a/test/test_sox_compatibility.py +++ b/test/test_sox_compatibility.py @@ -299,7 +299,3 @@ def test_perf_biquad_filtering(self): data, path = self.get_whitenoise() result = F.lfilter(data, torch.tensor([a0, a1, a2]), torch.tensor([b0, b1, b2])) self.assert_sox_effect(result, path, ['biquad', b0, b1, b2, a0, a1, a2]) - - -if __name__ == "__main__": - unittest.main() diff --git a/test/test_sox_effects.py b/test/test_sox_effects.py index e459cd7b01..86dfbc244a 100644 --- a/test/test_sox_effects.py +++ b/test/test_sox_effects.py @@ -270,7 +270,3 @@ def test_vad(self): y = vad(x_orig) self.assertTrue(x.allclose(y, rtol=1e-4, atol=1e-4)) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_transforms.py b/test/test_transforms.py index 6df9562bc8..f6942e18a5 100644 --- a/test/test_transforms.py +++ b/test/test_transforms.py @@ -219,7 +219,3 @@ def test_compute_deltas_twochannel(self): computed = transform(specgram) assert computed.shape == expected.shape, (computed.shape, expected.shape) self.assertEqual(computed, expected, atol=1e-6, rtol=1e-8) - - -if __name__ == '__main__': - unittest.main()