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
55
66 from aubio import note2midi, freq2note, note2freq, float_type
77 from numpy.testing import TestCase
8−from _tools import parametrize, assert_raises
8+from _tools import parametrize, assert_raises, skipTest
99
1010 list_of_known_notes = (
1111 ( 'C-1', 0 ),
@@ -53,16 +53,19 @@ class Test_note2midi_good_values: · 41 unmodified lines
5353
5454 @parametrize('note, midi', list_of_known_notes_with_unicode_issues)
5555 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 "
5757 try:
5858 assert note2midi(note) == midi
5959 except UnicodeEncodeError as e:
60+ # platforms with decoding failures include:
61+ # - osx: python <= 2.7.10
62+ # - win: python <= 2.7.12
6063 import sys
61− strfmt = "len(u'\\U0001D12A') != 1, excpected decoding failure | {:s} | {:s} {:s}"
62− strres = strfmt.format(e, sys.platform, sys.version)
63− # happens with: darwin 2.7.10, windows 2.7.12
64+ strmsg = "len(u'\\U0001D12A') != 1, expected decoding failure"
65+ strmsg += " | upgrade to Python 3 to fix"
66+ strmsg += " | {:s} | {:s} {:s}"
6467 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))
6669 else:
6770 raise
6871
@@ -135,5 +138,5 @@ class note2freq_simple_test(TestCase): · 66 unmodified lines
135138 self.assertLess(abs(note2freq("A4")-440), 1.e-12)
136139
137140 if __name__ == '__main__':
138− from unittest import main
139− main()
141+ import sys, pytest
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