changeset 124:ae61528436f1

Fix test.
author Jeremy Thurgood <firxen@gmail.com>
date Mon, 02 Sep 2013 16:52:03 +0200
parents 23b533d6f27e
children 12be9632fa15
files nagslang/tests/test_game_object.py
diffstat 1 files changed, 24 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/nagslang/tests/test_game_object.py	Mon Sep 02 16:43:15 2013 +0200
+++ b/nagslang/tests/test_game_object.py	Mon Sep 02 16:52:03 2013 +0200
@@ -17,6 +17,18 @@
         return self._shapes
 
 
+class FakeGameObject(object):
+    def __init__(self, shape, space):
+        self._shape = shape
+        self._space = space
+
+    def get_shape(self):
+        return self._shape
+
+    def get_space(self):
+        return self._space
+
+
 class FakePuzzler(game_object.Puzzler):
     def __init__(self, fake_state):
         self.fake_state = fake_state
@@ -26,17 +38,24 @@
 
 
 class TestPuzzles(TestCase):
+    def mkpuzzler(self, gobj, cls, *args, **kw):
+        puzzler = cls(*args, **kw)
+        puzzler.set_game_object(gobj)
+        return puzzler
+
     def test_floor_switch_puzzler(self):
-        puzzler = game_object.FloorSwitchPuzzler(FakeSpace(), None)
+        gobj = FakeGameObject(None, FakeSpace())
+        puzzler = self.mkpuzzler(gobj, game_object.FloorSwitchPuzzler)
         self.assertFalse(puzzler.get_state())
 
-        puzzler = game_object.FloorSwitchPuzzler(
-            FakeSpace(FakeShape()), None)
+        gobj = FakeGameObject(None, FakeSpace(FakeShape()))
+        puzzler = self.mkpuzzler(gobj, game_object.FloorSwitchPuzzler)
         self.assertFalse(puzzler.get_state())
 
         for collision_type in SWITCH_PUSHERS:
-            puzzler = game_object.FloorSwitchPuzzler(
-                FakeSpace(FakeShape(collision_type)), None)
+            gobj = FakeGameObject(
+                None, FakeSpace(FakeShape(collision_type)))
+            puzzler = self.mkpuzzler(gobj, game_object.FloorSwitchPuzzler)
             self.assertTrue(puzzler.get_state())
 
     def test_state_proxy_puzzler(self):