コード例 #1
0
class keyUpTest(unittest.TestCase):

    def setUp(self):
        """Call before every test case."""
        self.pong = PongGame()
        self.pong.init()

    def tearDown(self):
        """Call after every test case."""

    def testKeyUp(self):
        test_paddle1_vel = self.pong.paddle1_vel-self.pong.DELTA_VELOCITY
        test_paddle2_vel = self.pong.paddle2_vel
        assert self.pong.keyup("up") == (test_paddle1_vel, test_paddle2_vel), 'key_up() #1 does not provide the right return value'    
        test_paddle1_vel = self.pong.paddle1_vel
        test_paddle2_vel = self.pong.paddle2_vel-self.pong.DELTA_VELOCITY
        assert self.pong.keyup("e") == (test_paddle1_vel, test_paddle2_vel), 'key_up() #2 does not provide the right return value'
コード例 #2
0
class drawBallTest(unittest.TestCase):

    def setUp(self):
        """Call before every test case."""
        self.pong = PongGame()
        self.pong.init()

    def tearDown(self):
        """Call after every test case."""

    def testDrawBall(self):
        self.aCanvas = Canvas()
        test_paddle1_pos = 200.0
        test_paddle2_pos = 150.0
        test_paddle1_vel = self.pong.DEFAULT_VELOCITY
        test_paddle2_vel = self.pong.DEFAULT_VELOCITY
        ball_radius = self.pong.BALL_RADIUS
        ball_pos = [300,200]
        color = "Black"
        assert self.pong.draw_ball(self.aCanvas, ball_pos, color) == (ball_pos, ball_radius, color, color), 'draw_ball() does not provide the right return value'
        color = "White"
        assert self.pong.draw_ball(self.aCanvas, ball_pos, color) == (ball_pos, ball_radius, color, color), 'draw_ball() does not provide the right return value'
コード例 #3
0
class initTest(unittest.TestCase):

    def setUp(self):
        """Call before every test case."""
        self.pong = PongGame()

    def tearDown(self):
        """Call after every test case."""

    def testInit(self):
        test_paddle1_pos = 200.0
        test_paddle2_pos = 150.0
        test_paddle1_vel = 5.0
        test_paddle2_vel = 5.0
        test_score1 = 0
        test_score2 = 0
        assert self.pong.init() == (test_paddle1_pos, test_paddle2_pos, test_paddle1_vel, test_paddle2_vel, test_score1, test_score2), 'init() does not provide the right return value'