def test_is_path_blocked(self): """tests that the is_path_blocked function returns True if there is an obstacle in the path""" obstacles.random.randint = lambda a, b: 1 obstacles.get_obstacles() result = obstacles.is_path_blocked(2, 0, 2, 20) obstacles.ob_be_gone() self.assertEqual(result, True)
def robot_start(): """This is the entry function, do not change""" global run global env name = name_robot() got_obstacles(name) while run == True: command = given_command(name) process_command(command, name) robot_movement(command, name) if env == False: world.text.world.blobal_bariables(0) obstacles.ob_be_gone() else: world.turtle.world.blobal_bariables(0) global direction global h_st global silent h_st = [] direction = 0 run = True silent = False env = False
def test_obstacle_postions(self): """tests that the obstacle_positons function prints out the coordinates of the obstacles""" obstacles.ob_be_gone() obstacles.random.randint = lambda a, b: 1 obstacles.get_obstacles() with patch('sys.stdout', new=StringIO()) as fake_out: obstacles.obstacle_positions() self.assertEqual( fake_out.getvalue(), """There are some obstacles: - At position 1,1 (to 5,5) - At position 1,1 (to 5,5)\n""")
def test_obstacle_list(self): """tests that the get_obstacles function returns a list of tupels""" obstacles.ob_be_gone() obstacles.random.randint = lambda a, b: 1 result = obstacles.get_obstacles() self.assertEqual(result, [(1, 1)])