Skip to content

Commit

Permalink
Merge pull request #59 from HDE/master
Browse files Browse the repository at this point in the history
Release v0.1.10
  • Loading branch information
yxd-hde authored Nov 25, 2019
2 parents b8a078c + fdb973b commit ae22a12
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ Version 0.1.9
-------------

- Support latest boto3.

Version 0.1.10
--------------

- Fix traceback output when exception happens.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2018 HDE, Inc.
Copyright (c) 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion lambda_local/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def execute(func, event, context):
err = sys.exc_info()
result = json.dumps({
"errorMessage": str(err[1]),
"stackTrace": traceback.extract_tb(err[2]),
"stackTrace": traceback.format_tb(err[2]),
"errorType": err[0].__name__
}, indent=4, separators=(',', ': '))
err_type = ERR_TYPE_EXCEPTION
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def run_tests(self):
sys.exit(pytest.main(self.test_args))


version = "0.1.9"
version = "0.1.10"

TEST_REQUIRE = ['pytest']
if sys.version_info[0] == 2:
Expand Down
37 changes: 36 additions & 1 deletion tests/test_direct_invocations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''
python-lambda-local: Test Direct Inovactions
python-lambda-local: Test Direct Invocations
(command-line and direct).
Meant for use with py.test.
Expand All @@ -13,6 +13,7 @@
import os
from lambda_local.main import run as lambda_run
from lambda_local.main import call as lambda_call
from lambda_local.main import ERR_TYPE_EXCEPTION
from lambda_local.context import Context


Expand All @@ -21,6 +22,10 @@ def my_lambda_function(event, context):
return 42


def my_failing_lambda_function(event, context):
raise Exception('Oh no')


def test_function_call_for_pytest():
(result, error_type) = lambda_call(
my_lambda_function, {}, Context(1))
Expand All @@ -30,6 +35,13 @@ def test_function_call_for_pytest():
assert result == 42


def test_handle_exceptions_gracefully():
(result, error_type) = lambda_call(
my_failing_lambda_function, {}, Context(1))

assert error_type is ERR_TYPE_EXCEPTION


def test_check_command_line():
request = json.dumps({})
request_file = 'check_command_line_event.json'
Expand All @@ -51,3 +63,26 @@ def test_check_command_line():

os.remove(request_file)
assert p.exitcode == 0


def test_check_command_line_error():
request = json.dumps({})
request_file = 'check_command_line_event.json'
with open(request_file, "w") as f:
f.write(request)

args = argparse.Namespace(event=request_file,
file='tests/test_direct_invocations.py',
function='my_failing_lambda_function',
timeout=1,
environment_variables='',
library=None,
version_name='',
arn_string=''
)
p = Process(target=lambda_run, args=(args,))
p.start()
p.join()

os.remove(request_file)
assert p.exitcode == 1

0 comments on commit ae22a12

Please sign in to comment.