def test_live_cell_with_three_live_neighbours_lives(self): game = Game.from_string( "x x\n" " x \n" " x\n" ) expected_game = Game.from_string( " x \n" " xx\n" " \n" ) self.scenario_validate_make_step(game, expected_game)
def test_create_game_from_string(self): game = Game.from_string( "xx\n" " \n" ) self.assertTrue(game.is_live(0, 0)) self.assertTrue(game.is_live(0, 1)) self.assertTrue(game.is_dead(1, 0)) self.assertTrue(game.is_dead(1, 1))
def test_all_cells_are_dead_after_creation_with_size(self): game = Game(3) for x in range(game.size): for y in range(game.size): self.assertTrue(game.is_dead(x, y))
def test_two_games_with_different_lattices_are_not_equal(self): game1 = Game.from_string(" ") game2 = Game.from_string("x") self.assertNotEqual(game1, game2)
def test_two_games_with_equal_lattices_are_equal(self): game1 = Game.from_string("x") game2 = Game.from_string("x") self.assertEqual(game1, game2)
def test_size_cannot_be_modified_after_creation(self): game = Game(3) with self.assertRaises(AttributeError): game.size = 4
def setUp(self): self.game = Game.from_string( " x \n" " \n" "xx \n" )