Changeset aee840b for python/tests
- Timestamp:
- Jan 12, 2014, 3:33:07 AM (11 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:
- 6f27719
- Parents:
- 8203ae5
- Location:
- python/tests
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_slicing.py
r8203ae5 raee840b 6 6 from aubio import slice_source_at_stamps 7 7 from utils import count_samples_in_file, count_samples_in_directory 8 from utils import get_default_test_sound 8 9 9 10 import tempfile … … 13 14 14 15 def setUp(self): 15 self.source_file = 'chocolate_1min.wav'16 self.source_file = get_default_test_sound(self) 16 17 self.output_dir = tempfile.mkdtemp(suffix = 'aubio_slicing_test_case') 17 18 … … 37 38 shutil.rmtree(self.output_dir) 38 39 40 class aubio_slicing_wrong_starts_test_case(TestCase): 41 42 def setUp(self): 43 self.source_file = get_default_test_sound(self) 44 self.output_dir = tempfile.mkdtemp(suffix = 'aubio_slicing_test_case') 45 46 def test_slice_start_empty(self): 47 regions_start = [] 48 self.assertRaises(ValueError, 49 slice_source_at_stamps, 50 self.source_file, regions_start, output_dir = self.output_dir) 51 52 def test_slice_start_none(self): 53 regions_start = None 54 self.assertRaises(ValueError, 55 slice_source_at_stamps, 56 self.source_file, regions_start, output_dir = self.output_dir) 57 58 def tearDown(self): 59 shutil.rmtree(self.output_dir) 60 61 class aubio_slicing_wrong_ends_test_case(TestCase): 62 63 def setUp(self): 64 self.source_file = get_default_test_sound(self) 65 self.output_dir = tempfile.mkdtemp(suffix = 'aubio_slicing_test_case') 66 67 def test_slice_wrong_ends(self): 68 regions_start = [i*1000 for i in range(1, 100)] 69 regions_end = [] 70 self.assertRaises (ValueError, 71 slice_source_at_stamps, self.source_file, regions_start, regions_end, 72 output_dir = self.output_dir) 73 74 def test_slice_no_ends(self): 75 regions_start = [i*1000 for i in range(1, 100)] 76 regions_end = None 77 slice_source_at_stamps (self.source_file, regions_start, regions_end, 78 output_dir = self.output_dir) 79 original_samples = count_samples_in_file(self.source_file) 80 written_samples = count_samples_in_directory(self.output_dir) 81 assert_equal(original_samples, written_samples, 82 "number samples written different from number of original samples") 83 84 def tearDown(self): 85 shutil.rmtree(self.output_dir) 86 39 87 if __name__ == '__main__': 40 88 from unittest import main -
python/tests/utils.py
r8203ae5 raee840b 12 12 datadir = os.path.join(os.path.dirname(__file__), rel_dir) 13 13 return glob.glob(os.path.join(datadir,'*.*')) 14 15 def get_default_test_sound(TestCase, rel_dir = 'sounds'): 16 all_sounds = list_all_sounds(rel_dir) 17 if len(all_sounds) == 0: 18 TestCase.skipTest("please add some sounds in \'python/tests/sounds\'") 19 else: 20 return all_sounds[0] 14 21 15 22 def array_from_yaml_file(filename):
Note: See TracChangeset
for help on using the changeset viewer.