1+ # pylint: disable=invalid-name
12# SPDX-FileCopyrightText: 2019 Kevin J. Walters for Adafruit Industries
23#
34# SPDX-License-Identifier: MIT
5+ # pylint: enable=invalid-name
46
57import unittest
6- from unittest .mock import Mock , MagicMock
78
89
910import os
1011
1112verbose = int (os .getenv ("TESTVERBOSE" , "2" ))
1213
14+ # pylint: disable=wrong-import-position
1315# adafruit_midi had an import usb_midi
1416import sys
1517
2224import adafruit_midi
2325
2426# Full monty
25- from adafruit_midi .channel_pressure import ChannelPressure
26- from adafruit_midi .control_change import ControlChange
2727from adafruit_midi .note_off import NoteOff
2828from adafruit_midi .note_on import NoteOn
29- from adafruit_midi .pitch_bend import PitchBend
30- from adafruit_midi .polyphonic_key_pressure import PolyphonicKeyPressure
31- from adafruit_midi .program_change import ProgramChange
32- from adafruit_midi .start import Start
33- from adafruit_midi .stop import Stop
3429from adafruit_midi .system_exclusive import SystemExclusive
35- from adafruit_midi .timing_clock import TimingClock
3630
31+ # pylint: enable=wrong-import-position
3732
33+ # pylint: disable=invalid-name
3834class Test_MIDIMessage_from_message_byte_tests (unittest .TestCase ):
39- def test_NoteOn_basic (self ):
35+ # pylint: enable=invalid-name
36+ def test_NoteOn_basic (self ): # pylint: disable=invalid-name
37+ # pylint: enable=invalid-name
4038 data = bytes ([0x90 , 0x30 , 0x7F ])
4139 ichannel = 0
4240
@@ -51,7 +49,8 @@ def test_NoteOn_basic(self):
5149 self .assertEqual (skipped , 0 )
5250 self .assertEqual (msg .channel , 0 )
5351
54- def test_NoteOn_awaitingthirdbyte (self ):
52+ def test_NoteOn_awaitingthirdbyte (self ): # pylint: disable=invalid-name
53+ # pylint: enable=invalid-name
5554 data = bytes ([0x90 , 0x30 ])
5655 ichannel = 0
5756
@@ -71,7 +70,8 @@ def test_NoteOn_awaitingthirdbyte(self):
7170 )
7271 self .assertEqual (skipped , 0 )
7372
74- def test_NoteOn_predatajunk (self ):
73+ def test_NoteOn_predatajunk (self ): # pylint: disable=invalid-name
74+ # pylint: enable=invalid-name
7575 data = bytes ([0x20 , 0x64 , 0x90 , 0x30 , 0x32 ])
7676 ichannel = 0
7777
@@ -90,7 +90,8 @@ def test_NoteOn_predatajunk(self):
9090 self .assertEqual (skipped , 2 )
9191 self .assertEqual (msg .channel , 0 )
9292
93- def test_NoteOn_prepartialsysex (self ):
93+ def test_NoteOn_prepartialsysex (self ): # pylint: disable=invalid-name
94+ # pylint: enable=invalid-name
9495 data = bytes ([0x01 , 0x02 , 0x03 , 0x04 , 0xF7 , 0x90 , 0x30 , 0x32 ])
9596 ichannel = 0
9697
@@ -118,15 +119,16 @@ def test_NoteOn_prepartialsysex(self):
118119 self .assertIsInstance (
119120 msg ,
120121 NoteOn ,
121- "NoteOn is expected if SystemExclusive is loaded otherwise it would be MIDIUnknownEvent" ,
122+ "NoteOn is expected if SystemExclusive is loaded otherwise it'd be MIDIUnknownEvent" ,
122123 )
123124 self .assertEqual (msg .note , 0x30 )
124125 self .assertEqual (msg .velocity , 0x32 )
125126 self .assertEqual (msgendidxplusone , 3 , "NoteOn message removed" )
126127 self .assertEqual (skipped , 0 )
127128 self .assertEqual (msg .channel , 0 )
128129
129- def test_NoteOn_postNoteOn (self ):
130+ def test_NoteOn_postNoteOn (self ): # pylint: disable=invalid-name
131+ # pylint: enable=invalid-name
130132 data = bytes ([0x90 | 0x08 , 0x30 , 0x7F , 0x90 | 0x08 , 0x37 , 0x64 ])
131133 ichannel = 8
132134
@@ -141,7 +143,8 @@ def test_NoteOn_postNoteOn(self):
141143 self .assertEqual (skipped , 0 )
142144 self .assertEqual (msg .channel , 8 )
143145
144- def test_NoteOn_postpartialNoteOn (self ):
146+ def test_NoteOn_postpartialNoteOn (self ): # pylint: disable=invalid-name
147+ # pylint: enable=invalid-name
145148 data = bytes ([0x90 , 0x30 , 0x7F , 0x90 , 0x37 ])
146149 ichannel = 0
147150
@@ -156,7 +159,8 @@ def test_NoteOn_postpartialNoteOn(self):
156159 self .assertEqual (skipped , 0 )
157160 self .assertEqual (msg .channel , 0 )
158161
159- def test_NoteOn_preotherchannel (self ):
162+ def test_NoteOn_preotherchannel (self ): # pylint: disable=invalid-name
163+ # pylint: enable=invalid-name
160164 data = bytes ([0x90 | 0x05 , 0x30 , 0x7F , 0x90 | 0x03 , 0x37 , 0x64 ])
161165 ichannel = 3
162166
@@ -171,7 +175,10 @@ def test_NoteOn_preotherchannel(self):
171175 self .assertEqual (skipped , 0 )
172176 self .assertEqual (msg .channel , 3 )
173177
174- def test_NoteOn_preotherchannelplusintermediatejunk (self ):
178+ def test_NoteOn_preotherchannelplusintermediatejunk (
179+ self ,
180+ ): # pylint: disable=invalid-name
181+ # pylint: enable=invalid-name
175182 data = bytes ([0x90 | 0x05 , 0x30 , 0x7F , 0x00 , 0x00 , 0x90 | 0x03 , 0x37 , 0x64 ])
176183 ichannel = 3
177184
@@ -188,7 +195,8 @@ def test_NoteOn_preotherchannelplusintermediatejunk(self):
188195 self .assertEqual (skipped , 0 )
189196 self .assertEqual (msg .channel , 3 )
190197
191- def test_NoteOn_wrongchannel (self ):
198+ def test_NoteOn_wrongchannel (self ): # pylint: disable=invalid-name
199+ # pylint: enable=invalid-name
192200 data = bytes ([0x95 , 0x30 , 0x7F ])
193201 ichannel = 3
194202
@@ -200,7 +208,8 @@ def test_NoteOn_wrongchannel(self):
200208 self .assertEqual (msgendidxplusone , 3 , "wrong channel message discarded" )
201209 self .assertEqual (skipped , 0 )
202210
203- def test_NoteOn_partialandpreotherchannel1 (self ):
211+ def test_NoteOn_partialandpreotherchannel1 (self ): # pylint: disable=invalid-name
212+ # pylint: enable=invalid-name
204213 data = bytes ([0x95 , 0x30 , 0x7F , 0x93 ])
205214 ichannel = 3
206215
@@ -214,7 +223,8 @@ def test_NoteOn_partialandpreotherchannel1(self):
214223 )
215224 self .assertEqual (skipped , 0 )
216225
217- def test_NoteOn_partialandpreotherchannel2 (self ):
226+ def test_NoteOn_partialandpreotherchannel2 (self ): # pylint: disable=invalid-name
227+ # pylint: enable=invalid-name
218228 data = bytes ([0x95 , 0x30 , 0x7F , 0x93 , 0x37 ])
219229 ichannel = 3
220230
@@ -228,7 +238,8 @@ def test_NoteOn_partialandpreotherchannel2(self):
228238 )
229239 self .assertEqual (skipped , 0 )
230240
231- def test_NoteOn_constructor_int (self ):
241+ def test_NoteOn_constructor_int (self ): # pylint: disable=invalid-name
242+ # pylint: enable=invalid-name
232243 object1 = NoteOn (60 , 0x7F )
233244
234245 self .assertEqual (object1 .note , 60 )
@@ -253,7 +264,8 @@ def test_NoteOn_constructor_int(self):
253264 self .assertEqual (object4 .velocity , 127 )
254265 self .assertIsNone (object4 .channel )
255266
256- def test_SystemExclusive_NoteOn (self ):
267+ def test_SystemExclusive_NoteOn (self ): # pylint: disable=invalid-name
268+ # pylint: enable=invalid-name
257269 data = bytes ([0xF0 , 0x42 , 0x01 , 0x02 , 0x03 , 0x04 , 0xF7 , 0x90 | 14 , 0x30 , 0x60 ])
258270 ichannel = 14
259271
@@ -281,7 +293,10 @@ def test_SystemExclusive_NoteOn(self):
281293 self .assertEqual (skipped , 0 )
282294 self .assertEqual (msg .channel , 14 )
283295
284- def test_SystemExclusive_NoteOn_premalterminatedsysex (self ):
296+ def test_SystemExclusive_NoteOn_premalterminatedsysex (
297+ self ,
298+ ): # pylint: disable=invalid-name
299+ # pylint: enable=invalid-name
285300 data = bytes ([0xF0 , 0x42 , 0x01 , 0x02 , 0x03 , 0x04 , 0xF0 , 0x90 , 0x30 , 0x32 ])
286301 ichannel = 0
287302
@@ -296,7 +311,8 @@ def test_SystemExclusive_NoteOn_premalterminatedsysex(self):
296311 skipped , 0 , "If SystemExclusive class is imported then this must be 0"
297312 )
298313
299- def test_Unknown_SinglebyteStatus (self ):
314+ def test_Unknown_SinglebyteStatus (self ): # pylint: disable=invalid-name
315+ # pylint: enable=invalid-name
300316 data = bytes ([0xFD ])
301317 ichannel = 0
302318
@@ -309,7 +325,8 @@ def test_Unknown_SinglebyteStatus(self):
309325 self .assertEqual (skipped , 0 )
310326 self .assertIsNone (msg .channel )
311327
312- def test_Empty (self ):
328+ def test_Empty (self ): # pylint: disable=invalid-name
329+ # pylint: enable=invalid-name
313330 data = bytes ([])
314331 ichannel = 0
315332
@@ -322,8 +339,11 @@ def test_Empty(self):
322339 self .assertEqual (skipped , 0 )
323340
324341
325- class Test_MIDIMessage_NoteOn_constructor (unittest .TestCase ):
326- def test_NoteOn_constructor_string (self ):
342+ class Test_MIDIMessage_NoteOn_constructor (
343+ unittest .TestCase
344+ ): # pylint: disable=invalid-name
345+ def test_NoteOn_constructor_string (self ): # pylint: disable=invalid-name
346+ # pylint: enable=invalid-name
327347 object1 = NoteOn ("C4" , 0x64 )
328348 self .assertEqual (object1 .note , 60 )
329349 self .assertEqual (object1 .velocity , 0x64 )
@@ -336,35 +356,39 @@ def test_NoteOn_constructor_string(self):
336356 self .assertEqual (object3 .note , 61 )
337357 self .assertEqual (object3 .velocity , 0 )
338358
339- def test_NoteOn_constructor_valueerror1 (self ):
359+ def test_NoteOn_constructor_valueerror1 (self ): # pylint: disable=invalid-name
340360 with self .assertRaises (ValueError ):
341361 NoteOn (60 , 0x80 ) # pylint is happier if return value not stored
342362
343- def test_NoteOn_constructor_valueerror2 (self ):
363+ def test_NoteOn_constructor_valueerror2 (self ): # pylint: disable=invalid-name
344364 with self .assertRaises (ValueError ):
345365 NoteOn (- 1 , 0x7F )
346366
347- def test_NoteOn_constructor_valueerror3 (self ):
367+ def test_NoteOn_constructor_valueerror3 (self ): # pylint: disable=invalid-name
348368 with self .assertRaises (ValueError ):
349369 NoteOn (128 , 0x7F )
350370
351- def test_NoteOn_constructor_upperrange1 (self ):
371+ def test_NoteOn_constructor_upperrange1 (self ): # pylint: disable=invalid-name
372+ # pylint: enable=invalid-name
352373 object1 = NoteOn ("G9" , 0x7F )
353374 self .assertEqual (object1 .note , 127 )
354375 self .assertEqual (object1 .velocity , 0x7F )
355376
356- def test_NoteOn_constructor_upperrange2 (self ):
377+ def test_NoteOn_constructor_upperrange2 (self ): # pylint: disable=invalid-name
357378 with self .assertRaises (ValueError ):
358379 NoteOn ("G#9" , 0x7F ) # just above max note
359380
360- def test_NoteOn_constructor_bogusstring (self ):
381+ def test_NoteOn_constructor_bogusstring (self ): # pylint: disable=invalid-name
361382 with self .assertRaises (ValueError ):
362383 NoteOn ("CC4" , 0x7F )
363384
364385
365- class Test_MIDIMessage_NoteOff_constructor (unittest .TestCase ):
386+ class Test_MIDIMessage_NoteOff_constructor (
387+ unittest .TestCase
388+ ): # pylint: disable=invalid-name
366389 # mostly cut and paste from NoteOn above
367- def test_NoteOff_constructor_string (self ):
390+ def test_NoteOff_constructor_string (self ): # pylint: disable=invalid-name
391+ # pylint: enable=invalid-name
368392 object1 = NoteOff ("C4" , 0x64 )
369393 self .assertEqual (object1 .note , 60 )
370394 self .assertEqual (object1 .velocity , 0x64 )
@@ -381,28 +405,29 @@ def test_NoteOff_constructor_string(self):
381405 self .assertEqual (object4 .note , 61 )
382406 self .assertEqual (object4 .velocity , 0 )
383407
384- def test_NoteOff_constructor_valueerror1 (self ):
408+ def test_NoteOff_constructor_valueerror1 (self ): # pylint: disable=invalid-name
385409 with self .assertRaises (ValueError ):
386410 NoteOff (60 , 0x80 )
387411
388- def test_NoteOff_constructor_valueerror2 (self ):
412+ def test_NoteOff_constructor_valueerror2 (self ): # pylint: disable=invalid-name
389413 with self .assertRaises (ValueError ):
390414 NoteOff (- 1 , 0x7F )
391415
392- def test_NoteOff_constructor_valueerror3 (self ):
416+ def test_NoteOff_constructor_valueerror3 (self ): # pylint: disable=invalid-name
393417 with self .assertRaises (ValueError ):
394418 NoteOff (128 , 0x7F )
395419
396- def test_NoteOff_constructor_upperrange1 (self ):
420+ def test_NoteOff_constructor_upperrange1 (self ): # pylint: disable=invalid-name
421+ # pylint: enable=invalid-name
397422 object1 = NoteOff ("G9" , 0x7F )
398423 self .assertEqual (object1 .note , 127 )
399424 self .assertEqual (object1 .velocity , 0x7F )
400425
401- def test_NoteOff_constructor_upperrange2 (self ):
426+ def test_NoteOff_constructor_upperrange2 (self ): # pylint: disable=invalid-name
402427 with self .assertRaises (ValueError ):
403428 NoteOff ("G#9" , 0x7F ) # just above max note
404429
405- def test_NoteOff_constructor_bogusstring (self ):
430+ def test_NoteOff_constructor_bogusstring (self ): # pylint: disable=invalid-name
406431 with self .assertRaises (ValueError ):
407432 NoteOff ("CC4" , 0x7F )
408433
0 commit comments