Changeset 36e8956 for python/tests
- Timestamp:
- May 14, 2016, 5:22:28 AM (9 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 3865924
- Parents:
- ed938a2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_source.py
red938a2 r36e8956 8 8 9 9 list_of_sounds = list_all_sounds('sounds') 10 default_test_sound = list_of_sounds[0] 10 11 samplerates = [0, 44100, 8000, 32000] 11 12 hop_sizes = [512, 1024, 64] … … 51 52 if read < f.hop_size: break 52 53 result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}" 53 result_params = total_frames / float(f.samplerate), total_frames, int(total_frames/f.hop_size), f.samplerate, f.uri54 print (result_str.format(*result_params))54 result_params = total_frames / float(f.samplerate), total_frames, total_frames//f.hop_size, f.samplerate, f.uri 55 #print (result_str.format(*result_params)) 55 56 return total_frames 56 57 … … 75 76 assert f.samplerate != 0 76 77 self.read_from_source(f) 77 78 @params(*list_of_sounds)79 def test_wrong_samplerate(self, p):80 try:81 f = source(p, -1)82 except ValueError as e:83 pass84 else:85 self.fail('negative samplerate does not raise ValueError')86 87 @params(*list_of_sounds)88 def test_wrong_hop_size(self, p):89 try:90 f = source(p, 0, -1)91 except ValueError as e:92 pass93 else:94 self.fail('negative hop_size does not raise ValueError')95 78 96 79 @params(*list_of_sounds) … … 124 107 self.assertEqual(duration, total_frames) 125 108 109 110 class aubio_source_test_wrong_params(TestCase): 111 112 def test_wrong_file(self): 113 with self.assertRaises(RuntimeError): 114 f = source('path_to/unexisting file.mp3') 115 116 def test_wrong_samplerate(self): 117 with self.assertRaises(ValueError): 118 f = source(default_test_sound, -1) 119 120 def test_wrong_hop_size(self): 121 with self.assertRaises(ValueError): 122 f = source(default_test_sound, 0, -1) 123 124 def test_wrong_channels(self): 125 with self.assertRaises(ValueError): 126 f = source(default_test_sound, 0, 0, -1) 127 128 def test_wrong_seek(self): 129 f = source(default_test_sound) 130 with self.assertRaises(ValueError): 131 f.seek(-1) 132 133 def test_wrong_seek_too_large(self): 134 f = source(default_test_sound) 135 try: 136 with self.assertRaises(ValueError): 137 f.seek(f.duration + f.samplerate * 10) 138 except AssertionError as e: 139 self.skipTest('seeking after end of stream failed raising ValueError') 140 126 141 class aubio_source_readmulti_test_case(aubio_source_read_test_case): 127 142 … … 134 149 result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}" 135 150 result_params = total_frames / float(f.samplerate), total_frames, f.channels, int(total_frames/f.hop_size), f.samplerate, f.uri 136 print (result_str.format(*result_params))151 #print (result_str.format(*result_params)) 137 152 return total_frames 138 153
Note: See TracChangeset
for help on using the changeset viewer.