1
+ # pylint: disable=invalid-name
1
2
# SPDX-FileCopyrightText: 2019 Kevin J. Walters for Adafruit Industries
2
3
#
3
4
# SPDX-License-Identifier: MIT
5
+ # pylint: enable=invalid-name
4
6
5
7
import unittest
6
- from unittest .mock import Mock , MagicMock
7
8
8
9
9
10
import os
10
11
11
12
verbose = int (os .getenv ("TESTVERBOSE" , "2" ))
12
13
14
+ # pylint: disable=wrong-import-position
13
15
# adafruit_midi had an import usb_midi
14
16
import sys
15
17
22
24
import adafruit_midi
23
25
24
26
# Full monty
25
- from adafruit_midi .channel_pressure import ChannelPressure
26
- from adafruit_midi .control_change import ControlChange
27
27
from adafruit_midi .note_off import NoteOff
28
28
from 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
34
29
from adafruit_midi .system_exclusive import SystemExclusive
35
- from adafruit_midi .timing_clock import TimingClock
36
30
31
+ # pylint: enable=wrong-import-position
37
32
33
+ # pylint: disable=invalid-name
38
34
class 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
40
38
data = bytes ([0x90 , 0x30 , 0x7F ])
41
39
ichannel = 0
42
40
@@ -51,7 +49,8 @@ def test_NoteOn_basic(self):
51
49
self .assertEqual (skipped , 0 )
52
50
self .assertEqual (msg .channel , 0 )
53
51
54
- def test_NoteOn_awaitingthirdbyte (self ):
52
+ def test_NoteOn_awaitingthirdbyte (self ): # pylint: disable=invalid-name
53
+ # pylint: enable=invalid-name
55
54
data = bytes ([0x90 , 0x30 ])
56
55
ichannel = 0
57
56
@@ -71,7 +70,8 @@ def test_NoteOn_awaitingthirdbyte(self):
71
70
)
72
71
self .assertEqual (skipped , 0 )
73
72
74
- def test_NoteOn_predatajunk (self ):
73
+ def test_NoteOn_predatajunk (self ): # pylint: disable=invalid-name
74
+ # pylint: enable=invalid-name
75
75
data = bytes ([0x20 , 0x64 , 0x90 , 0x30 , 0x32 ])
76
76
ichannel = 0
77
77
@@ -90,7 +90,8 @@ def test_NoteOn_predatajunk(self):
90
90
self .assertEqual (skipped , 2 )
91
91
self .assertEqual (msg .channel , 0 )
92
92
93
- def test_NoteOn_prepartialsysex (self ):
93
+ def test_NoteOn_prepartialsysex (self ): # pylint: disable=invalid-name
94
+ # pylint: enable=invalid-name
94
95
data = bytes ([0x01 , 0x02 , 0x03 , 0x04 , 0xF7 , 0x90 , 0x30 , 0x32 ])
95
96
ichannel = 0
96
97
@@ -118,15 +119,16 @@ def test_NoteOn_prepartialsysex(self):
118
119
self .assertIsInstance (
119
120
msg ,
120
121
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" ,
122
123
)
123
124
self .assertEqual (msg .note , 0x30 )
124
125
self .assertEqual (msg .velocity , 0x32 )
125
126
self .assertEqual (msgendidxplusone , 3 , "NoteOn message removed" )
126
127
self .assertEqual (skipped , 0 )
127
128
self .assertEqual (msg .channel , 0 )
128
129
129
- def test_NoteOn_postNoteOn (self ):
130
+ def test_NoteOn_postNoteOn (self ): # pylint: disable=invalid-name
131
+ # pylint: enable=invalid-name
130
132
data = bytes ([0x90 | 0x08 , 0x30 , 0x7F , 0x90 | 0x08 , 0x37 , 0x64 ])
131
133
ichannel = 8
132
134
@@ -141,7 +143,8 @@ def test_NoteOn_postNoteOn(self):
141
143
self .assertEqual (skipped , 0 )
142
144
self .assertEqual (msg .channel , 8 )
143
145
144
- def test_NoteOn_postpartialNoteOn (self ):
146
+ def test_NoteOn_postpartialNoteOn (self ): # pylint: disable=invalid-name
147
+ # pylint: enable=invalid-name
145
148
data = bytes ([0x90 , 0x30 , 0x7F , 0x90 , 0x37 ])
146
149
ichannel = 0
147
150
@@ -156,7 +159,8 @@ def test_NoteOn_postpartialNoteOn(self):
156
159
self .assertEqual (skipped , 0 )
157
160
self .assertEqual (msg .channel , 0 )
158
161
159
- def test_NoteOn_preotherchannel (self ):
162
+ def test_NoteOn_preotherchannel (self ): # pylint: disable=invalid-name
163
+ # pylint: enable=invalid-name
160
164
data = bytes ([0x90 | 0x05 , 0x30 , 0x7F , 0x90 | 0x03 , 0x37 , 0x64 ])
161
165
ichannel = 3
162
166
@@ -171,7 +175,10 @@ def test_NoteOn_preotherchannel(self):
171
175
self .assertEqual (skipped , 0 )
172
176
self .assertEqual (msg .channel , 3 )
173
177
174
- def test_NoteOn_preotherchannelplusintermediatejunk (self ):
178
+ def test_NoteOn_preotherchannelplusintermediatejunk (
179
+ self ,
180
+ ): # pylint: disable=invalid-name
181
+ # pylint: enable=invalid-name
175
182
data = bytes ([0x90 | 0x05 , 0x30 , 0x7F , 0x00 , 0x00 , 0x90 | 0x03 , 0x37 , 0x64 ])
176
183
ichannel = 3
177
184
@@ -188,7 +195,8 @@ def test_NoteOn_preotherchannelplusintermediatejunk(self):
188
195
self .assertEqual (skipped , 0 )
189
196
self .assertEqual (msg .channel , 3 )
190
197
191
- def test_NoteOn_wrongchannel (self ):
198
+ def test_NoteOn_wrongchannel (self ): # pylint: disable=invalid-name
199
+ # pylint: enable=invalid-name
192
200
data = bytes ([0x95 , 0x30 , 0x7F ])
193
201
ichannel = 3
194
202
@@ -200,7 +208,8 @@ def test_NoteOn_wrongchannel(self):
200
208
self .assertEqual (msgendidxplusone , 3 , "wrong channel message discarded" )
201
209
self .assertEqual (skipped , 0 )
202
210
203
- def test_NoteOn_partialandpreotherchannel1 (self ):
211
+ def test_NoteOn_partialandpreotherchannel1 (self ): # pylint: disable=invalid-name
212
+ # pylint: enable=invalid-name
204
213
data = bytes ([0x95 , 0x30 , 0x7F , 0x93 ])
205
214
ichannel = 3
206
215
@@ -214,7 +223,8 @@ def test_NoteOn_partialandpreotherchannel1(self):
214
223
)
215
224
self .assertEqual (skipped , 0 )
216
225
217
- def test_NoteOn_partialandpreotherchannel2 (self ):
226
+ def test_NoteOn_partialandpreotherchannel2 (self ): # pylint: disable=invalid-name
227
+ # pylint: enable=invalid-name
218
228
data = bytes ([0x95 , 0x30 , 0x7F , 0x93 , 0x37 ])
219
229
ichannel = 3
220
230
@@ -228,7 +238,8 @@ def test_NoteOn_partialandpreotherchannel2(self):
228
238
)
229
239
self .assertEqual (skipped , 0 )
230
240
231
- def test_NoteOn_constructor_int (self ):
241
+ def test_NoteOn_constructor_int (self ): # pylint: disable=invalid-name
242
+ # pylint: enable=invalid-name
232
243
object1 = NoteOn (60 , 0x7F )
233
244
234
245
self .assertEqual (object1 .note , 60 )
@@ -253,7 +264,8 @@ def test_NoteOn_constructor_int(self):
253
264
self .assertEqual (object4 .velocity , 127 )
254
265
self .assertIsNone (object4 .channel )
255
266
256
- def test_SystemExclusive_NoteOn (self ):
267
+ def test_SystemExclusive_NoteOn (self ): # pylint: disable=invalid-name
268
+ # pylint: enable=invalid-name
257
269
data = bytes ([0xF0 , 0x42 , 0x01 , 0x02 , 0x03 , 0x04 , 0xF7 , 0x90 | 14 , 0x30 , 0x60 ])
258
270
ichannel = 14
259
271
@@ -281,7 +293,10 @@ def test_SystemExclusive_NoteOn(self):
281
293
self .assertEqual (skipped , 0 )
282
294
self .assertEqual (msg .channel , 14 )
283
295
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
285
300
data = bytes ([0xF0 , 0x42 , 0x01 , 0x02 , 0x03 , 0x04 , 0xF0 , 0x90 , 0x30 , 0x32 ])
286
301
ichannel = 0
287
302
@@ -296,7 +311,8 @@ def test_SystemExclusive_NoteOn_premalterminatedsysex(self):
296
311
skipped , 0 , "If SystemExclusive class is imported then this must be 0"
297
312
)
298
313
299
- def test_Unknown_SinglebyteStatus (self ):
314
+ def test_Unknown_SinglebyteStatus (self ): # pylint: disable=invalid-name
315
+ # pylint: enable=invalid-name
300
316
data = bytes ([0xFD ])
301
317
ichannel = 0
302
318
@@ -309,7 +325,8 @@ def test_Unknown_SinglebyteStatus(self):
309
325
self .assertEqual (skipped , 0 )
310
326
self .assertIsNone (msg .channel )
311
327
312
- def test_Empty (self ):
328
+ def test_Empty (self ): # pylint: disable=invalid-name
329
+ # pylint: enable=invalid-name
313
330
data = bytes ([])
314
331
ichannel = 0
315
332
@@ -322,8 +339,11 @@ def test_Empty(self):
322
339
self .assertEqual (skipped , 0 )
323
340
324
341
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
327
347
object1 = NoteOn ("C4" , 0x64 )
328
348
self .assertEqual (object1 .note , 60 )
329
349
self .assertEqual (object1 .velocity , 0x64 )
@@ -336,35 +356,39 @@ def test_NoteOn_constructor_string(self):
336
356
self .assertEqual (object3 .note , 61 )
337
357
self .assertEqual (object3 .velocity , 0 )
338
358
339
- def test_NoteOn_constructor_valueerror1 (self ):
359
+ def test_NoteOn_constructor_valueerror1 (self ): # pylint: disable=invalid-name
340
360
with self .assertRaises (ValueError ):
341
361
NoteOn (60 , 0x80 ) # pylint is happier if return value not stored
342
362
343
- def test_NoteOn_constructor_valueerror2 (self ):
363
+ def test_NoteOn_constructor_valueerror2 (self ): # pylint: disable=invalid-name
344
364
with self .assertRaises (ValueError ):
345
365
NoteOn (- 1 , 0x7F )
346
366
347
- def test_NoteOn_constructor_valueerror3 (self ):
367
+ def test_NoteOn_constructor_valueerror3 (self ): # pylint: disable=invalid-name
348
368
with self .assertRaises (ValueError ):
349
369
NoteOn (128 , 0x7F )
350
370
351
- def test_NoteOn_constructor_upperrange1 (self ):
371
+ def test_NoteOn_constructor_upperrange1 (self ): # pylint: disable=invalid-name
372
+ # pylint: enable=invalid-name
352
373
object1 = NoteOn ("G9" , 0x7F )
353
374
self .assertEqual (object1 .note , 127 )
354
375
self .assertEqual (object1 .velocity , 0x7F )
355
376
356
- def test_NoteOn_constructor_upperrange2 (self ):
377
+ def test_NoteOn_constructor_upperrange2 (self ): # pylint: disable=invalid-name
357
378
with self .assertRaises (ValueError ):
358
379
NoteOn ("G#9" , 0x7F ) # just above max note
359
380
360
- def test_NoteOn_constructor_bogusstring (self ):
381
+ def test_NoteOn_constructor_bogusstring (self ): # pylint: disable=invalid-name
361
382
with self .assertRaises (ValueError ):
362
383
NoteOn ("CC4" , 0x7F )
363
384
364
385
365
- class Test_MIDIMessage_NoteOff_constructor (unittest .TestCase ):
386
+ class Test_MIDIMessage_NoteOff_constructor (
387
+ unittest .TestCase
388
+ ): # pylint: disable=invalid-name
366
389
# 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
368
392
object1 = NoteOff ("C4" , 0x64 )
369
393
self .assertEqual (object1 .note , 60 )
370
394
self .assertEqual (object1 .velocity , 0x64 )
@@ -381,28 +405,29 @@ def test_NoteOff_constructor_string(self):
381
405
self .assertEqual (object4 .note , 61 )
382
406
self .assertEqual (object4 .velocity , 0 )
383
407
384
- def test_NoteOff_constructor_valueerror1 (self ):
408
+ def test_NoteOff_constructor_valueerror1 (self ): # pylint: disable=invalid-name
385
409
with self .assertRaises (ValueError ):
386
410
NoteOff (60 , 0x80 )
387
411
388
- def test_NoteOff_constructor_valueerror2 (self ):
412
+ def test_NoteOff_constructor_valueerror2 (self ): # pylint: disable=invalid-name
389
413
with self .assertRaises (ValueError ):
390
414
NoteOff (- 1 , 0x7F )
391
415
392
- def test_NoteOff_constructor_valueerror3 (self ):
416
+ def test_NoteOff_constructor_valueerror3 (self ): # pylint: disable=invalid-name
393
417
with self .assertRaises (ValueError ):
394
418
NoteOff (128 , 0x7F )
395
419
396
- def test_NoteOff_constructor_upperrange1 (self ):
420
+ def test_NoteOff_constructor_upperrange1 (self ): # pylint: disable=invalid-name
421
+ # pylint: enable=invalid-name
397
422
object1 = NoteOff ("G9" , 0x7F )
398
423
self .assertEqual (object1 .note , 127 )
399
424
self .assertEqual (object1 .velocity , 0x7F )
400
425
401
- def test_NoteOff_constructor_upperrange2 (self ):
426
+ def test_NoteOff_constructor_upperrange2 (self ): # pylint: disable=invalid-name
402
427
with self .assertRaises (ValueError ):
403
428
NoteOff ("G#9" , 0x7F ) # just above max note
404
429
405
- def test_NoteOff_constructor_bogusstring (self ):
430
+ def test_NoteOff_constructor_bogusstring (self ): # pylint: disable=invalid-name
406
431
with self .assertRaises (ValueError ):
407
432
NoteOff ("CC4" , 0x7F )
408
433
0 commit comments