changeset 527:6ef7cc57b94b

Monkey-patch albow.resource.get_image() in tests to avoid having to set up pygame display stuff.
author Jeremy Thurgood <firxen@gmail.com>
date Thu, 09 Sep 2010 11:11:37 +0200
parents a984cf27b527
children 0ce08d5e2acb
files gamelib/tests/game_logic_utils.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/tests/game_logic_utils.py	Wed Sep 08 17:33:07 2010 +0200
+++ b/gamelib/tests/game_logic_utils.py	Thu Sep 09 11:11:37 2010 +0200
@@ -7,10 +7,16 @@
 from gamelib.constants import SCREEN
 
 
-# We need this stuff set up so we can load images and whatnot.
-pygame.display.init()
-pygame.font.init()
-pygame.display.set_mode(SCREEN, SWSURFACE)
+# Monkey-patch albow.resource.get_image to not do alpha-conversion,
+# which would require pygame display intialisation, which we don't
+# really want in the tests.
+import albow.resource
+
+def get_image_unoptimized(*names, **kw):
+    kw.setdefault('optimize', False)
+    return albow.resource._get_image(names, **kw)
+
+albow.resource.get_image = get_image_unoptimized
 
 
 class GameLogicTestCase(unittest.TestCase):