Exemple #1
0
    def assert_combine_behaviour(self, tests, expTestCount, expTestIds):

        combined = combine(*tests)

        self.assertTrue(isinstance(combined, TestSuite),
            "should return a TestSuite")
        numTestCases = combined.countTestCases()
        self.assertEquals(numTestCases, expTestCount,
            "should have %d test cases, had %s" % (expTestCount, numTestCases))

        class NullStream(object):
            def write(*args):
                pass

        TextTestRunner(stream=NullStream()).run(combined)
        self.assertEquals(self.testIds, expTestIds,
            "combined suite was %s, should be %s" % (self.testIds, expTestIds))
Exemple #2
0
def run_all_tests():
    suite = combine(
        AcceptanceTest_test,
        Gameloop_test,
        Keyboard_test,
        Poly_test,
        Chunk_test,
        LevelBuilder_test,
        Room_test,
        World_test,
        Material_test,
        Disc_test,
        Block_test,
        TestImage_test,
        Listener_test,
        TestCase_test,
        Camera_test,
        Screenshot_test,
        Renderer_test,
        AT001,
    )
    run(suite)
Exemple #3
0
        self.gameloop.paused = True

        self.gameloop.run()

        self.assertFalse(self.gameloop.world.tick.triggered, "not paused")


    def test_toggle_pause(self):
        self.gameloop.toggle_pause()
        self.assertTrue(self.gameloop.paused, "didn't pause")
        self.gameloop.toggle_pause()
        self.assertFalse(self.gameloop.paused, "didn't unpause")


    def test_quit(self):
        self.gameloop.window = Mock()
        self.gameloop.window.close = lambda: None
        self.gameloop.window.has_exit = False
        self.gameloop.quit_game()
        self.assertTrue(self.gameloop.window.has_exit, "window not closed")


Gameloop_test = combine(
    Gameloop_test_with_window,
    Gameloop_test_without,
)

if __name__ == "__main__":
    run(Gameloop_test)

Exemple #4
0

class Irregular_test(MyTestCase):
    def test_irregular(self):
        start = Vec2d(3, -4)
        face = Vec2d(-6, 0)
        radius = 5
        # irregular poly's circle center is at (0, 0)
        num_verts = 5
        actual = irregular(start, face, radius, num_verts)
        self.assertEquals(len(actual), 5)
        self.assertEquals(actual[0], Vec2d(+3, -4))
        self.assertEquals(actual[1], Vec2d(-3, -4))
        for point in actual:
            self.assertAlmostEquals(point.get_length_sqrd(), 25.0)

    def test_irregular_impossible(self):
        start = Vec2d(-10, -0)
        face = Vec2d(20, 0)
        radius = 9
        num_verts = 3
        self.assertRaises(lambda: irregular(start, face, radius, num_verts), ValueError)


Poly_test = combine(
    Creation_test, Assert_valid_test, Offset_verts_test, Area_test, Centroid_test, Circle_center_test, Irregular_test
)

if __name__ == "__main__":
    run(Poly_test)
Exemple #5
0
        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")


TestCase_test = combine(
    TestCase_module_functions_test,
    TestCase_assertEquals_test,
    TestCase_assertRaises_test,
    TestCase_assertValidColor_test,
    TestCase_assertVertsEqual,
    combine_test,
    run_test,
)

if __name__ == "__main__":
    main()