History

[tests] [win/osx] improve skipTest encoding errors on py2.7

Paul Brossier committed 8 years ago

Commit 00fcc5d1 parent a3f26951 file · +11 −8Browse files

Showing the changes to python/tests (1 of 1 file). Show all

Unified · Split

python/tests/test_note2midi.py+11−8
@@ -5,7 +5,7 @@ from __future__ import unicode_literals · 4 unmodified lines
5 5
6from aubio import note2midi, freq2note, note2freq, float_type6from aubio import note2midi, freq2note, note2freq, float_type
7from numpy.testing import TestCase7from numpy.testing import TestCase
8from _tools import parametrize, assert_raises8from _tools import parametrize, assert_raises, skipTest
9 9
10list_of_known_notes = (10list_of_known_notes = (
11 ( 'C-1', 0 ),11 ( 'C-1', 0 ),
@@ -53,16 +53,19 @@ class Test_note2midi_good_values: · 41 unmodified lines
53 53
54 @parametrize('note, midi', list_of_known_notes_with_unicode_issues)54 @parametrize('note, midi', list_of_known_notes_with_unicode_issues)
55 def test_note2midi_known_values_with_unicode_issues(self, note, midi):55 def test_note2midi_known_values_with_unicode_issues(self, note, midi):
56 " known values are correctly converted, unless decoding is expected to fail"56 " difficult values are correctly converted unless expected failure "
57 try:57 try:
58 assert note2midi(note) == midi58 assert note2midi(note) == midi
59 except UnicodeEncodeError as e:59 except UnicodeEncodeError as e:
60 # platforms with decoding failures include:
61 # - osx: python <= 2.7.10
62 # - win: python <= 2.7.12
60 import sys63 import sys
61 strfmt = "len(u'\\U0001D12A') != 1, excpected decoding failure | {:s} | {:s} {:s}"64 strmsg = "len(u'\\U0001D12A') != 1, expected decoding failure"
62 strres = strfmt.format(e, sys.platform, sys.version)65 strmsg += " | upgrade to Python 3 to fix"
63 # happens with: darwin 2.7.10, windows 2.7.1266 strmsg += " | {:s} | {:s} {:s}"
64 if len('\U0001D12A') != 1 and sys.version[0] == '2':67 if len('\U0001D12A') != 1 and sys.version[0] == '2':
65 skipTest(strres + " | upgrade to Python 3 to fix")68 skipTest(strmsg.format(repr(e), sys.platform, sys.version))
66 else:69 else:
67 raise70 raise
68 71
@@ -135,5 +138,5 @@ class note2freq_simple_test(TestCase): · 66 unmodified lines
135 self.assertLess(abs(note2freq("A4")-440), 1.e-12)138 self.assertLess(abs(note2freq("A4")-440), 1.e-12)
136 139
137if __name__ == '__main__':140if __name__ == '__main__':
138 from unittest import main141 import sys, pytest
139 main()142 pytest.main(sys.argv)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t