14
14
LAMBDA_PRELUDE = """
15
15
from __future__ import print_function
16
16
17
+ import time
18
+
17
19
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
18
20
import sentry_sdk
19
21
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
29
23
30
- def flush(self, timeout, callback=None):
24
+ class TestTransport(HttpTransport):
25
+ def _send_event(self, event):
31
26
# Delay event output like this to test proper shutdown
32
27
# Note that AWS Lambda trunchates the log output to 4kb, so you better
33
28
# pray that your events are smaller than that or else tests start
34
29
# 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))
38
32
39
33
def init_sdk(**extra_init_args):
40
34
sentry_sdk.init(
41
- transport=TestTransport(),
35
+ dsn="https://123abc@example.com/123",
36
+ transport=TestTransport,
42
37
integrations=[AwsLambdaIntegration()],
38
+ shutdown_timeout=10,
43
39
**extra_init_args
44
40
)
45
41
"""
@@ -58,7 +54,7 @@ def lambda_client():
58
54
)
59
55
60
56
61
- @pytest .fixture (params = ["python3.6" , "python3.7" , "python2.7" ])
57
+ @pytest .fixture (params = ["python3.6" , "python3.7" , "python3.8" , " python2.7" ])
62
58
def run_lambda_function (tmpdir , lambda_client , request , semaphore_normalize ):
63
59
def inner (code , payload ):
64
60
runtime = request .param
0 commit comments