class GameBoard(Frame): game = numgame.NumGame() def __init__(self, parent): Frame.__init__(self, parent, background='white') self.parent = parent self.initUI() def initUI(self): self.parent.title("Number Guessing Game") self.pack(fill=BOTH, expand=1)
def test_new_game_100(self): # game.new_game() game = numgame.NumGame() self.assertTrue(game.target >= 0) self.assertTrue(game.target <= 100)
def test_check_guess_higher(self): game = numgame.NumGame() game.target = 55 self.assertTrue(game.check_guess(56) == 1)
def test_check_guess_lower(self): game = numgame.NumGame() game.target = 55 self.assertTrue(game.check_guess(54) == -1)
def test_check_guess_actual(self): game = numgame.NumGame() game.target = 55 self.assertTrue(game.check_guess(55) == 0)
def test_range1000(self): game = numgame.NumGame() game.new_game(1000) self.assertTrue(game.target >= 0) self.assertTrue(game.target <= 1000)