Commits

metagriffin committed 2341b48

added pygame.event.wait(timeout) unit test

  • Participants
  • Parent commits 11baed8

Comments (0)

Files changed (1)

File test/event_test.py

     from test.test_utils import test_not_implemented, unittest
 import pygame
 from pygame.compat import as_unicode
+import time
 
 ################################################################################
 
 
         pygame.event.post ( pygame.event.Event(2) )
         self.assert_(pygame.event.wait())
-        
+
+    def test_wait_timeout(self):
+        pygame.event.post ( pygame.event.Event(2) )
+        self.assertEquals(pygame.event.wait(100).type, 2)
+        t0 = time.time()
+        self.assertTrue(pygame.event.wait(100) is None)
+        t1 = time.time()
+        self.assertTrue(t1 - t0 < 0.11)
+        self.assertTrue(t1 - t0 > 0.09)
+
     def test_peek(self):
 
         # __doc__ (as of 2008-06-25) for pygame.event.peek: