Exemple #1
0
 def test_return_values(self):
     listener = Listener()
     listener.return_values = [4, 3, 2]
     self.assertEquals(listener(), 4, "set return value list 1")
     self.assertEquals(listener(), 3, "set return value list 2")
     self.assertEquals(listener(), 2, "set return value list 3")
     self.assertEquals(listener(), None, "set return value list over 1")
     self.assertEquals(listener(), None, "set return value list over 2")
Exemple #2
0
 def test_return_values_with_return_value(self):
     listener = Listener()
     listener.return_values = [4, 3, 2]
     listener.return_value = 456
     self.assertEquals(listener(), 4, "set return value list 1")
     self.assertEquals(listener(), 3, "set return value list 2")
     self.assertEquals(listener(), 2, "set return value list 3")
     self.assertEquals(listener(), 456, "set return value list over 1")
     self.assertEquals(listener(), 456, "set return value list over 2")
Exemple #3
0
 def test_reset(self):
     listener = Listener()
     listener.return_values = [4, 3, 2]
     listener.return_value = 456
     listener(1, 2, 3, a=7, b=8, c=9)
     listener(4, 5, 6, c=10, d=11, e=12)
     listener.reset()
     self.assert_is_reset(listener)
     self.assertEquals(listener(), 2, "reset messed with return_values")
     self.assertEquals(listener(), 456, "reset messed with return_value")
    def test_new_room_verts_tri_on_final_wall(self):
        builder = LevelBuilder()
        room = Listener()
        room.verts = [(1, 11), (2, 22), (3, 33), (4, 44)]
        wall = 3

        verts = builder.new_room_verts(room, wall, 3)

        self.assertEquals(len(verts), 3)
        self.assertEquals(verts[0], (1, 11))
        self.assertEquals(verts[1], (4, 44))
    def test_new_room_verts(self):
        builder = LevelBuilder()
        room = Listener()
        room.verts = [(1, 11), (2, 22), (3, 33), (4, 44)]
        wall = 1
        for num_verts in xrange(3, 5):

            verts = builder.new_room_verts(room, wall, num_verts)

            self.assertEquals(len(verts), num_verts)
            self.assertEquals(verts[0], (3, 33))
            self.assertEquals(verts[1], (2, 22))
    def test_select_branch_wall(self):
        builder = LevelBuilder()
        room = Listener()
        room.verts = range(5)
        room.neighbours = {0: object(), 2:object(), 3:object()}
        walls = set()

        for _ in xrange(32):
            walls.add(builder.select_branch_wall(room))

        self.assertTrue(0 not in walls)
        self.assertTrue(2 not in walls)
        self.assertTrue(3 not in walls)
Exemple #7
0
 def test_passes_verbosity(self):
     mockRunner = Listener()
     mockRunner.return_value = TextTestRunner()
     mockRun = Listener()
     mockRunner.return_value.run = mockRun
     from solescion.testutils import testcase as testcase_module
     orig = testcase_module.TextTestRunner
     testcase_module.TextTestRunner = mockRunner
     try:
         suite = ClassUnderTest("testAlwaysPasses")
         run(suite, verbosity=33)
     finally:
         testcase_module.TextTestRunner = orig
     self.assertEquals(mockRunner.kwargs['verbosity'], 33,
         "didnt create a verbose runner")
     self.assertEquals(mockRun.args, (suite,), "didnt run suite")
Exemple #8
0
 def test_return_value(self):
     listener = Listener()
     self.assertNone(listener(), "default return value")
     listener.return_value = 456
     self.assertEquals(listener(), 456, "set return value 1")
     self.assertEquals(listener(), 456, "set return value 2")
 def test_select_branch_wall_no_free_walls(self):
     builder = LevelBuilder()
     room = Listener()
     room.verts = range(3)
     room.neighbours = range(3)
     self.assertNone(builder.select_branch_wall(room))