# HG changeset patch # User Jeremy Thurgood # Date 1284023497 -7200 # Node ID 6ef7cc57b94bf401e1509a7a2820fcaa4729084d # Parent a984cf27b527da947ce17a338acf63ee2b5c25bc Monkey-patch albow.resource.get_image() in tests to avoid having to set up pygame display stuff. diff -r a984cf27b527 -r 6ef7cc57b94b gamelib/tests/game_logic_utils.py --- 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):