diff --git a/src_c/cython/pygame/pypm.pyx b/src_c/cython/pygame/pypm.pyx index d45e4aa9c0..8b47b89377 100644 --- a/src_c/cython/pygame/pypm.pyx +++ b/src_c/cython/pygame/pypm.pyx @@ -146,6 +146,7 @@ cdef extern from "porttime.h": ctypedef long PtTimestamp ctypedef void (* PtCallback)(PtTimestamp timestamp, void *userData) PtError Pt_Start(int resolution, PtCallback *callback, void *userData) + PtError Pt_Stop() PtTimestamp Pt_Time() cdef long _pypm_initialized @@ -171,6 +172,7 @@ def Terminate(): your system may crash. """ + Pt_Stop() Pm_Terminate() _pypm_initialized = 0 diff --git a/test/midi_test.py b/test/midi_test.py index 6b5d7f5420..f4189a2351 100644 --- a/test/midi_test.py +++ b/test/midi_test.py @@ -1,5 +1,4 @@ import unittest -import sys import pygame @@ -320,14 +319,8 @@ def test_get_init(self): def test_time(self): mtime = pygame.midi.time() self.assertIsInstance(mtime, int) - if "pytest" in sys.modules: - # under pytest the midi module takes a couple of seconds to init - # instead of milliseconds - self.assertGreaterEqual(mtime, 0) - self.assertLess(mtime, 3000) - else: - self.assertGreaterEqual(mtime, 0) - self.assertLess(mtime, 100) + # should be close to 2-3... since the timer is just init'd. + self.assertTrue(0 <= mtime < 100) class MidiModuleNonInteractiveTest(unittest.TestCase):