def test_move(self): test_human = Human("James", energy=50) self.assertEqual(test_human.move(50), True, "Return should be true.") test_human = Human("James", energy=50) self.assertEqual(test_human.move(60), False, "Return should be false.") test_human = Human("James", energy=50) test_human.move(30) self.assertEqual(test_human.energy, 20, "Energy should be thirty.")
def test_player_Can_make_a_move(): output = [] input_values = ["7"] def mock_input(s): output.append(s) return input_values.pop(0) human.input = mock_input class Moves(): def __init__(self): self.legal_moves = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0]] hum = Human(Moves()) number = hum.move() assert number >= 0 and number <= 6
def __repr__(self): return f"planet(humans={self.inhabitants['humans']}, robots={self.inhabitants['robots']})" if (__name__ == "__main__"): #------------------------ planet = Planet() human = Human() robot = Robot() #------------------------ print(planet.__repr__()) print(planet.__str__()) #------------------------ Will = Human("Will", 19) Will.move(30) planet.add_human(Will) Libby = Human("Libby", 11) Libby.move(10) Libby.eat(5) planet.add_human(Libby) #------------------------ Beep = Robot("Beep") Beep.move(60) Beep.eat(25) planet.add_robot(Beep) #------------------------ print("") print(planet.__repr__()) print(planet.__str__())