Skip to content

Commit c77a123

Browse files
authored
Minor improvements (#2714)
- better name for Pyramid event processor - better test data and output for AWS Lambda tests - one better asset in threading test - minor tox cleanup to make gevent more prominent
1 parent 2186e22 commit c77a123

File tree

5 files changed

+48
-40
lines changed

5 files changed

+48
-40
lines changed

sentry_sdk/integrations/pyramid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def size_of_file(self, postdata):
215215

216216
def _make_event_processor(weak_request, integration):
217217
# type: (Callable[[], Request], PyramidIntegration) -> EventProcessor
218-
def event_processor(event, hint):
218+
def pyramid_event_processor(event, hint):
219219
# type: (Dict[str, Any], Dict[str, Any]) -> Dict[str, Any]
220220
request = weak_request()
221221
if request is None:
@@ -231,4 +231,4 @@ def event_processor(event, hint):
231231

232232
return event
233233

234-
return event_processor
234+
return pyramid_event_processor

tests/integrations/aws_lambda/client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def run_lambda_function(
240240
FunctionName=full_fn_name,
241241
)
242242
print(
243-
"Lambda function in AWS already existing, taking it (and do not create a local one)"
243+
f"Lambda function {full_fn_name} in AWS already existing, taking it (and do not create a local one)"
244244
)
245245
except client.exceptions.ResourceNotFoundException:
246246
function_exists_in_aws = False
@@ -251,9 +251,14 @@ def run_lambda_function(
251251
dir_already_existing = os.path.isdir(base_dir)
252252

253253
if dir_already_existing:
254-
print("Local Lambda function directory already exists, skipping creation")
254+
print(
255+
f"Local Lambda function directory ({base_dir}) already exists, skipping creation"
256+
)
255257

256258
if not dir_already_existing:
259+
print(
260+
f"Creating Lambda function package ({full_fn_name}) locally in directory {base_dir}"
261+
)
257262
os.mkdir(base_dir)
258263
_create_lambda_package(
259264
base_dir, code, initial_handler, layer, syntax_check, subprocess_kwargs
@@ -316,9 +321,10 @@ def clean_up():
316321

317322
waiter = client.get_waiter("function_active_v2")
318323
waiter.wait(FunctionName=full_fn_name)
324+
print(f"Created Lambda function in AWS: {full_fn_name}")
319325
except client.exceptions.ResourceConflictException:
320326
print(
321-
"Lambda function already exists, this is fine, we will just invoke it."
327+
f"Lambda function ({full_fn_name}) already existing in AWS, this is fine, we will just invoke it."
322328
)
323329

324330
response = client.invoke(

tests/integrations/aws_lambda/test_aws.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -462,23 +462,23 @@ def test_handler(event, context):
462462
[
463463
{
464464
"headers": {
465-
"Host": "x.io",
466-
"X-Forwarded-Proto": "http"
465+
"Host": "x1.io",
466+
"X-Forwarded-Proto": "https"
467467
},
468468
"httpMethod": "GET",
469-
"path": "/somepath",
469+
"path": "/path1",
470470
"queryStringParameters": {
471-
"done": "true"
471+
"done": "false"
472472
},
473473
"dog": "Maisey"
474474
},
475475
{
476476
"headers": {
477-
"Host": "x.io",
477+
"Host": "x2.io",
478478
"X-Forwarded-Proto": "http"
479479
},
480-
"httpMethod": "GET",
481-
"path": "/somepath",
480+
"httpMethod": "POST",
481+
"path": "/path2",
482482
"queryStringParameters": {
483483
"done": "true"
484484
},
@@ -539,11 +539,11 @@ def test_handler(event, context):
539539

540540
if has_request_data:
541541
request_data = {
542-
"headers": {"Host": "x.io", "X-Forwarded-Proto": "http"},
542+
"headers": {"Host": "x1.io", "X-Forwarded-Proto": "https"},
543543
"method": "GET",
544-
"url": "http://x.io/somepath",
544+
"url": "https://x1.io/path1",
545545
"query_string": {
546-
"done": "true",
546+
"done": "false",
547547
},
548548
}
549549
else:

tests/integrations/threading/test_threading.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ def run(self):
131131
t.join()
132132
del t
133133

134-
assert not gc.collect()
134+
unreachable_objects = gc.collect()
135+
assert unreachable_objects == 0
135136

136137

137138
@pytest.mark.forked

tox.ini

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ envlist =
88
# === Common ===
99
{py2.7,py3.5,py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-common
1010

11+
# === Gevent ===
12+
{py2.7,py3.6,py3.8,py3.10,py3.11}-gevent
13+
1114
# === Integrations ===
1215
# General format is {pythonversion}-{integrationname}-v{frameworkversion}
1316
# 1 blank line between different integrations
@@ -112,9 +115,6 @@ envlist =
112115
{py3.10,py3.11,py3.12}-flask-v{3}
113116
{py3.10,py3.11,py3.12}-flask-latest
114117

115-
# Gevent
116-
{py2.7,py3.6,py3.8,py3.10,py3.11}-gevent
117-
118118
# GCP
119119
{py3.7}-gcp
120120

@@ -235,18 +235,32 @@ deps =
235235
# with the -r flag
236236
-r test-requirements.txt
237237

238-
py3.8-common: hypothesis
239-
240238
linters: -r linter-requirements.txt
241239
linters: werkzeug<2.3.0
242240

243-
# Common
241+
# === Common ===
242+
py3.8-common: hypothesis
244243
{py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-common: pytest-asyncio<=0.21.1
245244
# See https://github.com/pytest-dev/pytest/issues/9621
246245
# and https://github.com/pytest-dev/pytest-forked/issues/67
247246
# for justification of the upper bound on pytest
248247
{py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-common: pytest<7.0.0
249248

249+
# === Gevent ===
250+
# See http://www.gevent.org/install.html#older-versions-of-python
251+
# for justification of the versions pinned below
252+
py3.5-gevent: gevent==20.9.0
253+
# See https://stackoverflow.com/questions/51496550/runtime-warning-greenlet-greenlet-size-changed
254+
# for justification why greenlet is pinned here
255+
py3.5-gevent: greenlet==0.4.17
256+
{py2.7,py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-gevent: gevent>=22.10.0, <22.11.0
257+
# See https://github.com/pytest-dev/pytest/issues/9621
258+
# and https://github.com/pytest-dev/pytest-forked/issues/67
259+
# for justification of the upper bound on pytest
260+
{py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-gevent: pytest<7.0.0
261+
262+
# === Integrations ===
263+
250264
# AIOHTTP
251265
aiohttp-v3.4: aiohttp~=3.4.0
252266
aiohttp-v3.8: aiohttp~=3.8.0
@@ -360,7 +374,8 @@ deps =
360374

361375
# FastAPI
362376
fastapi: httpx
363-
fastapi: anyio<4.0.0 # thats a dep of httpx
377+
# (this is a dependency of httpx)
378+
fastapi: anyio<4.0.0
364379
fastapi: pytest-asyncio<=0.21.1
365380
fastapi: python-multipart
366381
fastapi: requests
@@ -379,19 +394,6 @@ deps =
379394
flask-v3: Flask~=3.0
380395
flask-latest: Flask
381396

382-
# Gevent
383-
# See http://www.gevent.org/install.html#older-versions-of-python
384-
# for justification of the versions pinned below
385-
py3.5-gevent: gevent==20.9.0
386-
# See https://stackoverflow.com/questions/51496550/runtime-warning-greenlet-greenlet-size-changed
387-
# for justification why greenlet is pinned here
388-
py3.5-gevent: greenlet==0.4.17
389-
{py2.7,py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-gevent: gevent>=22.10.0, <22.11.0
390-
# See https://github.com/pytest-dev/pytest/issues/9621
391-
# and https://github.com/pytest-dev/pytest-forked/issues/67
392-
# for justification of the upper bound on pytest
393-
{py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-gevent: pytest<7.0.0
394-
395397
# GQL
396398
gql-v{3.4}: gql[all]~=3.4.0
397399
gql-latest: gql[all]
@@ -525,7 +527,8 @@ deps =
525527
starlette: python-multipart
526528
starlette: requests
527529
starlette: httpx
528-
starlette: anyio<4.0.0 # thats a dep of httpx
530+
# (this is a dependency of httpx)
531+
starlette: anyio<4.0.0
529532
starlette: jinja2
530533
starlette-v0.19: starlette~=0.19.0
531534
starlette-v0.20: starlette~=0.20.0
@@ -540,7 +543,6 @@ deps =
540543
starlite: requests
541544
starlite: cryptography
542545
starlite: pydantic<2.0.0
543-
{py3.8,py3.9}-starlite: typing-extensions==4.5.0 # this is used by pydantic, which is used by starlite. When the problem is fixed in here or pydantic, this can be removed
544546
starlite-v{1.48}: starlite~=1.48.0
545547
starlite-v{1.51}: starlite~=1.51.0
546548

@@ -576,6 +578,7 @@ deps =
576578
setenv =
577579
PYTHONDONTWRITEBYTECODE=1
578580
common: TESTPATH=tests
581+
gevent: TESTPATH=tests
579582
aiohttp: TESTPATH=tests/integrations/aiohttp
580583
ariadne: TESTPATH=tests/integrations/ariadne
581584
arq: TESTPATH=tests/integrations/arq
@@ -593,8 +596,6 @@ setenv =
593596
falcon: TESTPATH=tests/integrations/falcon
594597
fastapi: TESTPATH=tests/integrations/fastapi
595598
flask: TESTPATH=tests/integrations/flask
596-
# run all tests with gevent
597-
gevent: TESTPATH=tests
598599
gcp: TESTPATH=tests/integrations/gcp
599600
gql: TESTPATH=tests/integrations/gql
600601
graphene: TESTPATH=tests/integrations/graphene

0 commit comments

Comments
 (0)