From 7d89e6187fffd9d6773778f192224ae6b12bd8b6 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 10 Mar 2013 11:37:28 -0500 Subject: [PATCH] tests/test_{midi2note,note2midi}.py: add header and encoding --- python/lib/aubio/midiconv.py | 4 ++-- python/tests/test_midi2note.py | 7 ++++--- python/tests/test_note2midi.py | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) mode change 100644 => 100755 python/tests/test_midi2note.py diff --git a/python/lib/aubio/midiconv.py b/python/lib/aubio/midiconv.py index e658290a..445afd89 100644 --- a/python/lib/aubio/midiconv.py +++ b/python/lib/aubio/midiconv.py @@ -1,10 +1,10 @@ -# -*- encoding: utf8 -*- +# -*- coding: utf-8 -*- def note2midi(note): " convert note name to midi note number, e.g. [C-1, G9] -> [0, 127] " _valid_notenames = {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11} _valid_modifiers = {None: 0, u'♮': 0, '#': +1, u'♯': +1, u'\udd2a': +2, 'b': -1, u'♭': -1, u'\ufffd': -2} - _valid_octaves = range(-1, 10) + _valid_octaves = range(-1, 10) if type(note) not in (str, unicode): raise TypeError, "a string is required, got %s" % note if not (1 < len(note) < 5): diff --git a/python/tests/test_midi2note.py b/python/tests/test_midi2note.py old mode 100644 new mode 100755 index cf865d6d..ce854bfb --- a/python/tests/test_midi2note.py +++ b/python/tests/test_midi2note.py @@ -1,4 +1,5 @@ -# -*- encoding: utf8 -*- +#! /usr/bin/env python +# -*- coding: utf-8 -*- from aubio import midi2note import unittest @@ -13,14 +14,14 @@ list_of_known_midis = ( ( 127, 'G9' ), ) -class TestMidi2NoteGoodValues(unittest.TestCase): +class midi2note_good_values(unittest.TestCase): def test_midi2note_known_values(self): " known values are correctly converted " for midi, note in list_of_known_midis: self.assertEqual ( midi2note(midi), note ) -class TestNote2MidiWrongValues(unittest.TestCase): +class midi2note_wrong_values(unittest.TestCase): def test_midi2note_negative_value(self): " fails when passed a negative value " diff --git a/python/tests/test_note2midi.py b/python/tests/test_note2midi.py index b22b6a31..77be8940 100755 --- a/python/tests/test_note2midi.py +++ b/python/tests/test_note2midi.py @@ -1,4 +1,5 @@ -# -*- encoding: utf8 -*- +#! /usr/bin/env python +# -*- coding: utf-8 -*- from aubio import note2midi import unittest @@ -22,14 +23,14 @@ list_of_known_notes = ( ( u'A♮2', 45 ), ) -class TestNote2MidiGoodValues(unittest.TestCase): +class note2midi_good_values(unittest.TestCase): def test_note2midi_known_values(self): " known values are correctly converted " for note, midi in list_of_known_notes: self.assertEqual ( note2midi(note), midi ) -class TestNote2MidiWrongValues(unittest.TestCase): +class note2midi_wrong_values(unittest.TestCase): def test_note2midi_missing_octave(self): " fails when passed only one character" -- 2.26.2