1. pygame
  2. Untitled project
  3. pygame

Commits

illume  committed b40a091

updated test to be more leniant on the value from the movie...

  • Participants
  • Parent commits 3b46565
  • Branches default

Comments (0)

Files changed (1)

File test/movie_test.py

View file
 
 # TODO fix bugs: checking to avoid segfaults
 
+
+
+def within(a,b, error_range):
+    return abs(a - b) < error_range
+
+def within_seq(a,b,error_range):
+    for x,y in zip(a,b):
+	#print x,y
+	if not within(x,y,error_range):
+	    return 0
+    return 1
+
+
+
 class MovieTypeTest( unittest.TestCase ):            
     def test_render_frame__off_screen(self):
         # __doc__ (as of 2008-06-25) for pygame.movie.Movie:
 
 	
         #self.assertEqual(off_screen.get_at((10,10)), (16, 16, 255, 255))
-        self.assert_(off_screen.get_at((10,10)) in [(16, 16, 255, 255), (18, 13, 238, 255)])
+        #self.assert_(off_screen.get_at((10,10)) in [(16, 16, 255, 255), (18, 13, 238, 255)])
+        self.assert_(within_seq( off_screen.get_at((10,10)), (16, 16, 255, 255), 20 ))
 
         pygame.display.quit()
 
         movie.render_frame(5)
         
         #self.assertEqual(screen.get_at((10,10)), (16, 16, 255, 255))
-        self.assert_(screen.get_at((10,10)) in [(16, 16, 255, 255), (18, 13, 238, 255)])
+        #self.assert_(screen.get_at((10,10)) in [(16, 16, 255, 255), (18, 13, 238, 255)])
+        self.assert_(within_seq( screen.get_at((10,10)), (16, 16, 255, 255), 20 ))
 
         pygame.display.quit()