Changeset 124:ae61528436f1


Ignore:
Timestamp:
Sep 2, 2013, 2:52:03 PM (7 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Message:

Fix test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/tests/test_game_object.py

    r110 r124  
    1818
    1919
     20class FakeGameObject(object):
     21    def __init__(self, shape, space):
     22        self._shape = shape
     23        self._space = space
     24
     25    def get_shape(self):
     26        return self._shape
     27
     28    def get_space(self):
     29        return self._space
     30
     31
    2032class FakePuzzler(game_object.Puzzler):
    2133    def __init__(self, fake_state):
     
    2739
    2840class TestPuzzles(TestCase):
     41    def mkpuzzler(self, gobj, cls, *args, **kw):
     42        puzzler = cls(*args, **kw)
     43        puzzler.set_game_object(gobj)
     44        return puzzler
     45
    2946    def test_floor_switch_puzzler(self):
    30         puzzler = game_object.FloorSwitchPuzzler(FakeSpace(), None)
     47        gobj = FakeGameObject(None, FakeSpace())
     48        puzzler = self.mkpuzzler(gobj, game_object.FloorSwitchPuzzler)
    3149        self.assertFalse(puzzler.get_state())
    3250
    33         puzzler = game_object.FloorSwitchPuzzler(
    34             FakeSpace(FakeShape()), None)
     51        gobj = FakeGameObject(None, FakeSpace(FakeShape()))
     52        puzzler = self.mkpuzzler(gobj, game_object.FloorSwitchPuzzler)
    3553        self.assertFalse(puzzler.get_state())
    3654
    3755        for collision_type in SWITCH_PUSHERS:
    38             puzzler = game_object.FloorSwitchPuzzler(
    39                 FakeSpace(FakeShape(collision_type)), None)
     56            gobj = FakeGameObject(
     57                None, FakeSpace(FakeShape(collision_type)))
     58            puzzler = self.mkpuzzler(gobj, game_object.FloorSwitchPuzzler)
    4059            self.assertTrue(puzzler.get_state())
    4160
Note: See TracChangeset for help on using the changeset viewer.