Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -7,7 +7,6 @@ from utils import list_all_sounds · 6 unmodified lines | |||
| 7 | from nose2.tools import params | 7 | from nose2.tools import params |
| 8 | 8 | ||
| 9 | list_of_sounds = list_all_sounds('sounds') | 9 | list_of_sounds = list_all_sounds('sounds') |
| 10 | default_test_sound = None | ||
| 11 | samplerates = [0, 44100, 8000, 32000] | 10 | samplerates = [0, 44100, 8000, 32000] |
| 12 | hop_sizes = [512, 1024, 64] | 11 | hop_sizes = [512, 1024, 64] |
| 13 | 12 | ||
| @@ -24,7 +23,7 @@ class aubio_source_test_case_base(TestCase): · 10 unmodified lines | |||
| 24 | 23 | ||
| 25 | def setUp(self): | 24 | def setUp(self): |
| 26 | if not len(list_of_sounds): self.skipTest('add some sound files in \'python/tests/sounds\'') | 25 | if not len(list_of_sounds): self.skipTest('add some sound files in \'python/tests/sounds\'') |
| 27 | default_test_sound = list_of_sounds[0] | 26 | self.default_test_sound = list_of_sounds[0] |
| 28 | 27 | ||
| 29 | class aubio_source_test_case(aubio_source_test_case_base): | 28 | class aubio_source_test_case(aubio_source_test_case_base): |
| 30 | 29 | ||
| @@ -114,27 +113,27 @@ class aubio_source_test_wrong_params(TestCase): · 83 unmodified lines | |||
| 114 | with self.assertRaises(RuntimeError): | 113 | with self.assertRaises(RuntimeError): |
| 115 | f = source('path_to/unexisting file.mp3') | 114 | f = source('path_to/unexisting file.mp3') |
| 116 | 115 | ||
| 117 | class aubio_source_test_wrong_params(aubio_source_test_case_base): | 116 | class aubio_source_test_wrong_params_with_file(aubio_source_test_case_base): |
| 118 | 117 | ||
| 119 | def test_wrong_samplerate(self): | 118 | def test_wrong_samplerate(self): |
| 120 | with self.assertRaises(ValueError): | 119 | with self.assertRaises(ValueError): |
| 121 | f = source(default_test_sound, -1) | 120 | f = source(self.default_test_sound, -1) |
| 122 | 121 | ||
| 123 | def test_wrong_hop_size(self): | 122 | def test_wrong_hop_size(self): |
| 124 | with self.assertRaises(ValueError): | 123 | with self.assertRaises(ValueError): |
| 125 | f = source(default_test_sound, 0, -1) | 124 | f = source(self.default_test_sound, 0, -1) |
| 126 | 125 | ||
| 127 | def test_wrong_channels(self): | 126 | def test_wrong_channels(self): |
| 128 | with self.assertRaises(ValueError): | 127 | with self.assertRaises(ValueError): |
| 129 | f = source(default_test_sound, 0, 0, -1) | 128 | f = source(self.default_test_sound, 0, 0, -1) |
| 130 | 129 | ||
| 131 | def test_wrong_seek(self): | 130 | def test_wrong_seek(self): |
| 132 | f = source(default_test_sound) | 131 | f = source(self.default_test_sound) |
| 133 | with self.assertRaises(ValueError): | 132 | with self.assertRaises(ValueError): |
| 134 | f.seek(-1) | 133 | f.seek(-1) |
| 135 | 134 | ||
| 136 | def test_wrong_seek_too_large(self): | 135 | def test_wrong_seek_too_large(self): |
| 137 | f = source(default_test_sound) | 136 | f = source(self.default_test_sound) |
| 138 | try: | 137 | try: |
| 139 | with self.assertRaises(ValueError): | 138 | with self.assertRaises(ValueError): |
| 140 | f.seek(f.duration + f.samplerate * 10) | 139 | f.seek(f.duration + f.samplerate * 10) |