Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions sample-apps/blank-python/function/lambda_function.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ class TestFunction(unittest.TestCase):

def test_function(self):
xray_recorder.begin_segment('test_function')
file = open('event.json', 'rb')
try:
ba = bytearray(file.read())
event = jsonpickle.decode(ba)
logger.warning('## EVENT')
logger.warning(jsonpickle.encode(event))
context = {'requestid' : '1234'}
result = handler(event, context)
print(str(result))
self.assertRegex(str(result), 'FunctionCount', 'Should match')
finally:
file.close()
file.close()
with open('event.json', 'rb') as file:
try:
ba = bytearray(file.read())
event = jsonpickle.decode(ba)
logger.warning('## EVENT')
logger.warning(jsonpickle.encode(event))
context = {'requestid' : '1234'}
result = handler(event, context)
print(result)
self.assertRegex(str(result), 'FunctionCount', 'Should match')
finally:
file.close()
Comment on lines -23 to +34
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestFunction.test_function refactored with the following changes:

xray_recorder.end_segment()

if __name__ == '__main__':
Expand Down