From 794d645856da721e0bc7e97a788dcc60e4c87f0c Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Mon, 3 Jan 2022 15:56:59 +0100 Subject: Refactored tests, dropped SimpleQueue usage --- midi_launchpad_mini_integrationtest.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'midi_launchpad_mini_integrationtest.py') diff --git a/midi_launchpad_mini_integrationtest.py b/midi_launchpad_mini_integrationtest.py index e5b757c..5a28925 100644 --- a/midi_launchpad_mini_integrationtest.py +++ b/midi_launchpad_mini_integrationtest.py @@ -6,11 +6,9 @@ from player_mock import Player as PlayerMock class MidiWrapperMock: def __init__(self): - from queue import SimpleQueue self.callback = None self.connectedDevice = None - self.sentMessages = SimpleQueue() - self.latestMessage = None + self.sentMessages = list() def setCallback(self, callback): self.callback = callback @@ -19,8 +17,7 @@ class MidiWrapperMock: self.connectedDevice = deviceName def sendMessage(self, note, velocity, channel): - self.latestMessage = (note, velocity, channel) - self.sentMessages.put(self.latestMessage) + self.sentMessages.append((note, velocity, channel)) def simulateInput(self, note, velocity=127, channel=0): if self.callback is not None: @@ -29,7 +26,7 @@ class MidiWrapperMock: self.callback(msg) def getLatestMessage(self): - return self.latestMessage + return self.sentMessages[-1] @pytest.fixture def playerMock(): @@ -231,9 +228,6 @@ def test_initializationMessages(uut, midiWrapperMock): uut.connect() - sentMessages = set() - while (not midiWrapperMock.sentMessages.empty()): - sentMessages.add(midiWrapperMock.sentMessages.get()) - - assert sentMessages == expectedMessages + sentMessagesSet = set(midiWrapperMock.sentMessages) + assert sentMessagesSet == expectedMessages -- cgit v1.2.3