Skip to content

Commit

Permalink
added comments to new code
Browse files Browse the repository at this point in the history
  • Loading branch information
Paris Goldman-Smith committed Sep 6, 2018
1 parent c609109 commit 4ae4bcb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions aimmo-game-worker/avatar_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def process_avatar_turn(self, world_map, avatar_state, src_code):

except Exception as e:
traceback_list = traceback.format_exc().split('\n')
user_traceback = self.format_user_traceback(traceback_list)
user_traceback = self.get_only_user_traceback(traceback_list)
for trace in user_traceback:
print(trace)

Expand All @@ -74,10 +74,10 @@ def decide_action(self, world_map, avatar_state):
raise InvalidActionException(action)
return action.serialise()

# If the traceback does not contain any reference to the user code, found by '<string>',
# then this method will just return the full traceback.
@staticmethod
def get_only_user_traceback(self, tb_list):
def get_only_user_traceback(tb_list):
""" If the traceback does not contain any reference to the user code, found by '<string>',
then this method will just return the full traceback. """
start_of_user_traceback = 0
for i in range(len(tb_list)):
if '<string>' in tb_list[i]:
Expand Down
8 changes: 4 additions & 4 deletions aimmo-game-worker/tests/test_avatar_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def handle_turn(self, world_map, avatar_state):
'''
runner = AvatarRunner()
response = runner.process_avatar_turn(world_map={}, avatar_state={}, src_code=avatar)
self.assertFalse(response['log'].__contains__('/usr/src/app/'))
self.assertFalse('/usr/src/app/' in response['log'])

def test_syntax_error_contains_only_user_traceback(self):
avatar = '''class Avatar(object):
Expand All @@ -142,7 +142,7 @@ def handle_turn(self, world_map, avatar_state):
'''
runner = AvatarRunner()
response = runner.process_avatar_turn(world_map={}, avatar_state={}, src_code=avatar)
self.assertFalse(response['log'].__contains__('/usr/src/app/'))
self.assertFalse('/usr/src/app/' in response['log'])

def test_invalid_action_exception_contains_only_user_traceback(self):
avatar1 = '''class Avatar(object):
Expand All @@ -163,6 +163,6 @@ def handle_turn(self, world_map, avatar_state):
'''
runner = AvatarRunner()
response = runner.process_avatar_turn(world_map={}, avatar_state={}, src_code=avatar1)
self.assertFalse(response['log'].__contains__('/usr/src/app/'))
self.assertFalse('/usr/src/app/' in response['log'])
response = runner.process_avatar_turn(world_map={}, avatar_state={}, src_code=avatar2)
self.assertFalse(response['log'].__contains__('/usr/src/app/'))
self.assertFalse('/usr/src/app/' in response['log'])

0 comments on commit 4ae4bcb

Please sign in to comment.