[tests] protect local variables to allow running with pytest
authorPaul Brossier <piem@piem.org>
Thu, 1 Nov 2018 01:52:12 +0000 (02:52 +0100)
committerPaul Brossier <piem@piem.org>
Thu, 1 Nov 2018 01:52:12 +0000 (02:52 +0100)
python/tests/test_pitch.py

index 749c37b..6305532 100755 (executable)
@@ -1,7 +1,6 @@
 #! /usr/bin/env python
 
-from unittest import TestCase, main
-from numpy.testing import assert_equal
+from numpy.testing import TestCase, assert_equal
 from numpy import sin, arange, mean, median, isnan, pi
 from aubio import fvec, pitch, freqtomidi, float_type
 
@@ -116,10 +115,11 @@ def create_test (algo, mode):
 
 for algo in pitch_algorithms:
     for mode in signal_modes:
-        test_method = create_test (algo, mode)
-        test_method.__name__ = 'test_pitch_%s_%d_%d_%dHz_sin_%.0f' % ( algo,
+        _test_method = create_test (algo, mode)
+        _test_method.__name__ = 'test_pitch_%s_%d_%d_%dHz_sin_%.0f' % ( algo,
                 mode[0], mode[1], mode[2], mode[3] )
-        setattr (aubio_pitch_Sinusoid, test_method.__name__, test_method)
+        setattr (aubio_pitch_Sinusoid, _test_method.__name__, _test_method)
 
 if __name__ == '__main__':
+    from unittest import main
     main()