Exemple #1
0
class golTestCase(unittest.TestCase):
    def setUp(self):
        self.game = Game()

    def test_uses_default_arguments(self):
        self.assertEqual(self.game.width, 80)
        self.assertEqual(self.game.height, 32)
        self.assertEqual(self.game.length, 100)
        self.assertEqual(self.game.interval, .1)

    def test_takes_arguments(self):
        tmp = Game(16, 9, 5, .5)
        self.assertEqual(tmp.width, 16)
        self.assertEqual(tmp.height, 9)
        self.assertEqual(tmp.length, 5)
        self.assertEqual(tmp.interval, .5)

    def test_generates_a_valid_random_start(self):
        self.assertIsNotNone(self.game.screen)
        self.assertIsNotNone(self.game.screen[3])
        self.assertTrue(self.game.screen[5][8] == 0 or
                        self.game.screen[5][8] == 1)

    def Dtest_prints_screen(self):
        self.game.print_screen()

    def test_generates_next_generation(self):
        old = self.game.screen
        self.game.gen_next_generation()
        self.assertNotEqual(old, self.game.screen)

    def test_lives(self):
        # game = Game(width=119, height=60)
        game = Game(width=100, height=64, length=500, interval=.01)
        # game = Game(width=23, height=35, length=50, interval=.1)
        game.live()
##############################################################################################
# Sample Aplication Importing Python Module Gol to play Game of Life
#
# Author: David Venegas - Email: [email protected]  
##############################################################################################

from gol import Game

game = Game(alive_color='black', dead_color='gainsboro', grid_color='gray56')
Exemple #3
0
 def setUp(self):
     self.game = Game()
Exemple #4
0
 def test_lives(self):
     # game = Game(width=119, height=60)
     game = Game(width=100, height=64, length=500, interval=.01)
     # game = Game(width=23, height=35, length=50, interval=.1)
     game.live()