comparison tests/test_AudioSource.py @ 216:3708f2eb8a40

Remove deprecated calls in AudioSource
author Amine Sehili <amine.sehili@gmail.com>
date Sat, 06 Jul 2019 11:17:54 +0100
parents 9047740c5092
children f16fc2c3d12b
comparison
equal deleted inserted replaced
215:e59b071b03cb 216:3708f2eb8a40
384 @genty_dataset(positive=((10000,)), negative=(-10000,)) 384 @genty_dataset(positive=((10000,)), negative=(-10000,))
385 def test_position_ms_setter_out_of_range(self, position_ms): 385 def test_position_ms_setter_out_of_range(self, position_ms):
386 with self.assertRaises(IndexError): 386 with self.assertRaises(IndexError):
387 self.audio_source.position_ms = position_ms 387 self.audio_source.position_ms = position_ms
388 388
389 def test_sr10_sw1_ch1_get_time_position_0(self): 389 def test_sr10_sw1_ch1_position_s_0(self):
390 tp = self.audio_source.get_time_position() 390 tp = self.audio_source.position_s
391 self.assertEqual( 391 self.assertEqual(
392 tp, 392 tp,
393 0.0, 393 0.0,
394 msg="wrong time position, expected: 0.0, found: {0} ".format(tp), 394 msg="wrong time position, expected: 0.0, found: {0} ".format(tp),
395 ) 395 )
396 396
397 def test_sr10_sw1_ch1_get_time_position_1(self): 397 def test_sr10_sw1_ch1_position_s_1(self):
398 srate = self.audio_source.get_sampling_rate() 398 srate = self.audio_source.get_sampling_rate()
399 # read one second 399 # read one second
400 self.audio_source.read(srate) 400 self.audio_source.read(srate)
401 tp = self.audio_source.get_time_position() 401 tp = self.audio_source.position_s
402 self.assertEqual( 402 self.assertEqual(
403 tp, 403 tp,
404 1.0, 404 1.0,
405 msg="wrong time position, expected: 1.0, found: {0} ".format(tp), 405 msg="wrong time position, expected: 1.0, found: {0} ".format(tp),
406 ) 406 )
407 407
408 def test_sr10_sw1_ch1_get_time_position_2_5(self): 408 def test_sr10_sw1_ch1_position_s_2_5(self):
409 # read 2.5 seconds 409 # read 2.5 seconds
410 self.audio_source.read(25) 410 self.audio_source.read(25)
411 tp = self.audio_source.get_time_position() 411 tp = self.audio_source.position_s
412 self.assertEqual( 412 self.assertEqual(
413 tp, 413 tp,
414 2.5, 414 2.5,
415 msg="wrong time position, expected: 2.5, found: {0} ".format(tp), 415 msg="wrong time position, expected: 2.5, found: {0} ".format(tp),
416 ) 416 )
417 417
418 def test_sr10_sw1_ch1_set_time_position_0(self): 418 def test_sr10_sw1_ch1_position_s_0(self):
419 self.audio_source.read(10) 419 self.audio_source.read(10)
420 self.audio_source.set_time_position(0) 420 self.audio_source.position_s = 0
421 tp = self.audio_source.get_time_position() 421 tp = self.audio_source.position_s
422 self.assertEqual( 422 self.assertEqual(
423 tp, 423 tp,
424 0.0, 424 0.0,
425 msg="wrong time position, expected: 0.0, found: {0} ".format(tp), 425 msg="wrong time position, expected: 0.0, found: {0} ".format(tp),
426 ) 426 )
427 427
428 def test_sr10_sw1_ch1_set_time_position_1(self): 428 def test_sr10_sw1_ch1_position_s_1(self):
429 self.audio_source.set_time_position(1) 429 self.audio_source.position_s = 1
430 tp = self.audio_source.get_time_position() 430 tp = self.audio_source.position_s
431 self.assertEqual( 431 self.assertEqual(
432 tp, 432 tp,
433 1.0, 433 1.0,
434 msg="wrong time position, expected: 1.0, found: {0} ".format(tp), 434 msg="wrong time position, expected: 1.0, found: {0} ".format(tp),
435 ) 435 )
601 msg="wrong stream position_s, expected: {}, found: {}".format( 601 msg="wrong stream position_s, expected: {}, found: {}".format(
602 expected_ms, position_ms 602 expected_ms, position_ms
603 ), 603 ),
604 ) 604 )
605 605
606 def test_sr16_sw2_ch1_read_set_position_0(self): 606 def test_sr16_sw2_ch1_read_position_0(self):
607 self.audio_source.read(10) 607 self.audio_source.read(10)
608 self.audio_source.position = 0 608 self.audio_source.position = 0
609 pos = self.audio_source.position 609 pos = self.audio_source.position
610 self.assertEqual( 610 self.assertEqual(
611 pos, 0, msg="wrong position, expected: 0, found: {0} ".format(pos) 611 pos, 0, msg="wrong position, expected: 0, found: {0} ".format(pos)
731 ) 731 )
732 732
733 def test_sr16_sw2_ch1_rewind(self): 733 def test_sr16_sw2_ch1_rewind(self):
734 self.audio_source.read(10) 734 self.audio_source.read(10)
735 self.audio_source.rewind() 735 self.audio_source.rewind()
736 tp = self.audio_source.get_position() 736 tp = self.audio_source.position
737 self.assertEqual( 737 self.assertEqual(
738 tp, 0, msg="wrong position, expected: 0.0, found: {0} ".format(tp) 738 tp, 0, msg="wrong position, expected: 0.0, found: {0} ".format(tp)
739 ) 739 )
740 740
741 def test_sr16_sw2_ch1_set_data(self): 741 def test_sr16_sw2_ch1_set_data(self):
869 msg="wrong number of channels, expected: 1, found: {0} ".format( 869 msg="wrong number of channels, expected: 1, found: {0} ".format(
870 channels 870 channels
871 ), 871 ),
872 ) 872 )
873 873
874 def test_sr11_sw4_ch1_get_position_0(self): 874 def test_sr11_sw4_ch1_position_0(self):
875 pos = self.audio_source.get_position() 875 pos = self.audio_source.position
876 self.assertEqual( 876 self.assertEqual(
877 pos, 0, msg="wrong position, expected: 0, found: {0} ".format(pos) 877 pos, 0, msg="wrong position, expected: 0, found: {0} ".format(pos)
878 ) 878 )
879 879
880 def test_sr11_sw4_ch1_get_position_5(self): 880 def test_sr11_sw4_ch1_position_5(self):
881 self.audio_source.read(5) 881 self.audio_source.read(5)
882 pos = self.audio_source.get_position() 882 pos = self.audio_source.position
883 self.assertEqual( 883 self.assertEqual(
884 pos, 5, msg="wrong position, expected: 5, found: {0} ".format(pos) 884 pos, 5, msg="wrong position, expected: 5, found: {0} ".format(pos)
885 ) 885 )
886 886
887 def test_sr11_sw4_ch1_get_position_9(self): 887 def test_sr11_sw4_ch1_position_9(self):
888 self.audio_source.read(5) 888 self.audio_source.read(5)
889 self.audio_source.read(4) 889 self.audio_source.read(4)
890 pos = self.audio_source.get_position() 890 pos = self.audio_source.position
891 self.assertEqual( 891 self.assertEqual(
892 pos, 9, msg="wrong position, expected: 5, found: {0} ".format(pos) 892 pos, 9, msg="wrong position, expected: 5, found: {0} ".format(pos)
893 ) 893 )
894 894
895 def test_sr11_sw4_ch1_set_position_0(self): 895 def test_sr11_sw4_ch1_position_0(self):
896 self.audio_source.read(10) 896 self.audio_source.read(10)
897 self.audio_source.set_position(0) 897 self.audio_source.position = 0
898 pos = self.audio_source.get_position() 898 pos = self.audio_source.position
899 self.assertEqual( 899 self.assertEqual(
900 pos, 0, msg="wrong position, expected: 0, found: {0} ".format(pos) 900 pos, 0, msg="wrong position, expected: 0, found: {0} ".format(pos)
901 ) 901 )
902 902
903 def test_sr11_sw4_ch1_set_position_10(self): 903 def test_sr11_sw4_ch1_position_10(self):
904 self.audio_source.set_position(10) 904 self.audio_source.position = 10
905 pos = self.audio_source.get_position() 905 pos = self.audio_source.position
906 self.assertEqual( 906 self.assertEqual(
907 pos, 907 pos,
908 10, 908 10,
909 msg="wrong position, expected: 10, found: {0} ".format(pos), 909 msg="wrong position, expected: 10, found: {0} ".format(pos),
910 ) 910 )
911 911
912 def test_sr11_sw4_ch1_get_time_position_0(self): 912 def test_sr11_sw4_ch1_position_s_0(self):
913 tp = self.audio_source.get_time_position() 913 tp = self.audio_source.position_s
914 self.assertEqual( 914 self.assertEqual(
915 tp, 915 tp,
916 0.0, 916 0.0,
917 msg="wrong time position, expected: 0.0, found: {0} ".format(tp), 917 msg="wrong time position, expected: 0.0, found: {0} ".format(tp),
918 ) 918 )
919 919
920 def test_sr11_sw4_ch1_get_time_position_1(self): 920 def test_sr11_sw4_ch1_position_s_1(self):
921 srate = self.audio_source.get_sampling_rate() 921 srate = self.audio_source.get_sampling_rate()
922 # read one second 922 # read one second
923 self.audio_source.read(srate) 923 self.audio_source.read(srate)
924 tp = self.audio_source.get_time_position() 924 tp = self.audio_source.position_s
925 self.assertEqual( 925 self.assertEqual(
926 tp, 926 tp,
927 1.0, 927 1.0,
928 msg="wrong time position, expected: 1.0, found: {0} ".format(tp), 928 msg="wrong time position, expected: 1.0, found: {0} ".format(tp),
929 ) 929 )
930 930
931 def test_sr11_sw4_ch1_get_time_position_0_63(self): 931 def test_sr11_sw4_ch1_position_s_0_63(self):
932 # read 2.5 seconds 932 # read 2.5 seconds
933 self.audio_source.read(7) 933 self.audio_source.read(7)
934 tp = self.audio_source.get_time_position() 934 tp = self.audio_source.position_s
935 self.assertAlmostEqual( 935 self.assertAlmostEqual(
936 tp, 936 tp,
937 0.636363636364, 937 0.636363636364,
938 msg="wrong time position, expected: 0.636363636364, " 938 msg="wrong time position, expected: 0.636363636364, "
939 "found: {0} ".format(tp), 939 "found: {0} ".format(tp),
940 ) 940 )
941 941
942 def test_sr11_sw4_ch1_set_time_position_0(self): 942 def test_sr11_sw4_ch1_position_s_0(self):
943 self.audio_source.read(10) 943 self.audio_source.read(10)
944 self.audio_source.set_time_position(0) 944 self.audio_source.position_s = 0
945 tp = self.audio_source.get_time_position() 945 tp = self.audio_source.position_s
946 self.assertEqual( 946 self.assertEqual(
947 tp, 947 tp,
948 0.0, 948 0.0,
949 msg="wrong time position, expected: 0.0, found: {0} ".format(tp), 949 msg="wrong time position, expected: 0.0, found: {0} ".format(tp),
950 ) 950 )
951 951
952 def test_sr11_sw4_ch1_set_time_position_1(self): 952 def test_sr11_sw4_ch1_position_s_1(self):
953 953
954 self.audio_source.set_time_position(1) 954 self.audio_source.position_s = 1
955 tp = self.audio_source.get_time_position() 955 tp = self.audio_source.position_s
956 self.assertEqual( 956 self.assertEqual(
957 tp, 957 tp,
958 1.0, 958 1.0,
959 msg="wrong time position, expected: 1.0, found: {0} ".format(tp), 959 msg="wrong time position, expected: 1.0, found: {0} ".format(tp),
960 ) 960 )