Skip to content

Commit 8b8766b

Browse files
committed
Fix stopping midi timer on midi.quit()
& undo test changes
1 parent ff88969 commit 8b8766b

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src_c/cython/pygame/pypm.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ cdef extern from "porttime.h":
146146
ctypedef long PtTimestamp
147147
ctypedef void (* PtCallback)(PtTimestamp timestamp, void *userData)
148148
PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
149+
PtError Pt_Stop()
149150
PtTimestamp Pt_Time()
150151

151152
cdef long _pypm_initialized
@@ -171,6 +172,7 @@ def Terminate():
171172
your system may crash.
172173
173174
"""
175+
Pt_Stop()
174176
Pm_Terminate()
175177
_pypm_initialized = 0
176178

test/midi_test.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import unittest
2-
import sys
32

43

54
import pygame
@@ -320,14 +319,8 @@ def test_get_init(self):
320319
def test_time(self):
321320
mtime = pygame.midi.time()
322321
self.assertIsInstance(mtime, int)
323-
if "pytest" in sys.modules:
324-
# under pytest the midi module takes a couple of seconds to init
325-
# instead of milliseconds
326-
self.assertGreaterEqual(mtime, 0)
327-
self.assertLess(mtime, 3000)
328-
else:
329-
self.assertGreaterEqual(mtime, 0)
330-
self.assertLess(mtime, 100)
322+
# should be close to 2-3... since the timer is just init'd.
323+
self.assertTrue(0 <= mtime < 100)
331324

332325

333326
class MidiModuleNonInteractiveTest(unittest.TestCase):

0 commit comments

Comments
 (0)