Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ae22a12

Browse files
authored
Merge pull request #59 from HDE/master
Release v0.1.10
2 parents b8a078c + fdb973b commit ae22a12

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed

‎CHANGELOG.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ Version 0.1.9
4747
-------------
4848

4949
- Support latest boto3.
50+
51+
Version 0.1.10
52+
--------------
53+
54+
- Fix traceback output when exception happens.

‎LICENSE‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

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

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎lambda_local/main.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def execute(func, event, context):
124124
err = sys.exc_info()
125125
result = json.dumps({
126126
"errorMessage": str(err[1]),
127-
"stackTrace": traceback.extract_tb(err[2]),
127+
"stackTrace": traceback.format_tb(err[2]),
128128
"errorType": err[0].__name__
129129
}, indent=4, separators=(',', ': '))
130130
err_type = ERR_TYPE_EXCEPTION

‎setup.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def run_tests(self):
2323
sys.exit(pytest.main(self.test_args))
2424

2525

26-
version = "0.1.9"
26+
version = "0.1.10"
2727

2828
TEST_REQUIRE = ['pytest']
2929
if sys.version_info[0] == 2:

‎tests/test_direct_invocations.py‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
python-lambda-local: Test Direct Inovactions
2+
python-lambda-local: Test Direct Invocations
33
(command-line and direct).
44
55
Meant for use with py.test.
@@ -13,6 +13,7 @@
1313
import os
1414
from lambda_local.main import run as lambda_run
1515
from lambda_local.main import call as lambda_call
16+
from lambda_local.main import ERR_TYPE_EXCEPTION
1617
from lambda_local.context import Context
1718

1819

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

2324

25+
def my_failing_lambda_function(event, context):
26+
raise Exception('Oh no')
27+
28+
2429
def test_function_call_for_pytest():
2530
(result, error_type) = lambda_call(
2631
my_lambda_function, {}, Context(1))
@@ -30,6 +35,13 @@ def test_function_call_for_pytest():
3035
assert result == 42
3136

3237

38+
def test_handle_exceptions_gracefully():
39+
(result, error_type) = lambda_call(
40+
my_failing_lambda_function, {}, Context(1))
41+
42+
assert error_type is ERR_TYPE_EXCEPTION
43+
44+
3345
def test_check_command_line():
3446
request = json.dumps({})
3547
request_file = 'check_command_line_event.json'
@@ -51,3 +63,26 @@ def test_check_command_line():
5163

5264
os.remove(request_file)
5365
assert p.exitcode == 0
66+
67+
68+
def test_check_command_line_error():
69+
request = json.dumps({})
70+
request_file = 'check_command_line_event.json'
71+
with open(request_file, "w") as f:
72+
f.write(request)
73+
74+
args = argparse.Namespace(event=request_file,
75+
file='tests/test_direct_invocations.py',
76+
function='my_failing_lambda_function',
77+
timeout=1,
78+
environment_variables='',
79+
library=None,
80+
version_name='',
81+
arn_string=''
82+
)
83+
p = Process(target=lambda_run, args=(args,))
84+
p.start()
85+
p.join()
86+
87+
os.remove(request_file)
88+
assert p.exitcode == 1

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /