def test_does_not_update_with_imports(self): avatar = '''class Avatar: def next_turn(self, world_map, avatar_state): import os return MoveAction(random.choice(direction.ALL_DIRECTIONS)) ''' runner = AvatarRunner() runner._update_avatar(src_code=avatar) with self.assertRaises(ImportError): runner.decide_action(world_map={}, avatar_state={})
def test_invalid_action_exception(self): avatar = '''class Avatar: def next_turn(self, world_map, avatar_state): new_dir = random.choice(direction.ALL_DIRECTIONS) ''' runner = AvatarRunner() runner._update_avatar(src_code=avatar) with self.assertRaises(InvalidActionException): runner.decide_action(world_map={}, avatar_state={})