Skip to content

Commit cb31fbf

Browse files
authored
fix: Test AWS Lambda under Python 3.8 (getsentry#562)
* fix: Test AWS Lambda under Python 3.8 * fix: Increase shutdown_timeout
1 parent ca375dc commit cb31fbf

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

tests/integrations/aws_lambda/test_aws.py

+11-15
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,28 @@
1414
LAMBDA_PRELUDE = """
1515
from __future__ import print_function
1616
17+
import time
18+
1719
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
1820
import sentry_sdk
1921
import json
20-
from sentry_sdk.transport import Transport
21-
22-
class TestTransport(Transport):
23-
def __init__(self):
24-
Transport.__init__(self)
25-
self._queue = []
26-
27-
def capture_event(self, event):
28-
self._queue.append(event)
22+
from sentry_sdk.transport import HttpTransport
2923
30-
def flush(self, timeout, callback=None):
24+
class TestTransport(HttpTransport):
25+
def _send_event(self, event):
3126
# Delay event output like this to test proper shutdown
3227
# Note that AWS Lambda trunchates the log output to 4kb, so you better
3328
# pray that your events are smaller than that or else tests start
3429
# failing.
35-
for event in self._queue:
36-
print("EVENT:", json.dumps(event))
37-
del self._queue[:]
30+
time.sleep(1)
31+
print("\\nEVENT:", json.dumps(event))
3832
3933
def init_sdk(**extra_init_args):
4034
sentry_sdk.init(
41-
transport=TestTransport(),
35+
dsn="https://123abc@example.com/123",
36+
transport=TestTransport,
4237
integrations=[AwsLambdaIntegration()],
38+
shutdown_timeout=10,
4339
**extra_init_args
4440
)
4541
"""
@@ -58,7 +54,7 @@ def lambda_client():
5854
)
5955

6056

61-
@pytest.fixture(params=["python3.6", "python3.7", "python2.7"])
57+
@pytest.fixture(params=["python3.6", "python3.7", "python3.8", "python2.7"])
6258
def run_lambda_function(tmpdir, lambda_client, request, semaphore_normalize):
6359
def inner(code, payload):
6460
runtime = request.param

0 commit comments

Comments
 (0)