Skip to content

Commit 4b61ff3

Browse files
committed
Test with and without executing
1 parent 01223b1 commit 4b61ff3

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

sentry_sdk/integrations/django/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def process_django_templates(event, hint):
157157
for i in reversed(range(len(frames))):
158158
f = frames[i]
159159
if (
160-
f.get("function") in ("Parser.parse", "render")
160+
f.get("function") in ("Parser.parse", "parse", "render")
161161
and f.get("module") == "django.template.base"
162162
):
163163
i += 1

test-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ pytest-cov==2.8.1
77
gevent
88
eventlet
99
newrelic
10-
executing

tests/integrations/django/test_basic.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from sentry_sdk import capture_message, capture_exception
1919
from sentry_sdk.integrations.django import DjangoIntegration
20+
from sentry_sdk.utils import executing
2021

2122
from tests.integrations.django.myapp.wsgi import application
2223

@@ -437,11 +438,19 @@ def test_template_exception(sentry_init, client, capture_events):
437438
filenames = [
438439
(f.get("function"), f.get("module")) for f in exception["stacktrace"]["frames"]
439440
]
440-
assert filenames[-3:] == [
441-
(u"Parser.parse", u"django.template.base"),
442-
(None, None),
443-
(u"Parser.invalid_block_tag", u"django.template.base"),
444-
]
441+
442+
if executing:
443+
assert filenames[-3:] == [
444+
(u"Parser.parse", u"django.template.base"),
445+
(None, None),
446+
(u"Parser.invalid_block_tag", u"django.template.base"),
447+
]
448+
else:
449+
assert filenames[-3:] == [
450+
(u"parse", u"django.template.base"),
451+
(None, None),
452+
(u"invalid_block_tag", u"django.template.base"),
453+
]
445454

446455

447456
@pytest.mark.parametrize(

tests/test_client.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from sentry_sdk import Hub, Client, configure_scope, capture_message, capture_exception
1111
from sentry_sdk.transport import Transport
1212
from sentry_sdk._compat import reraise, text_type, PY2
13-
from sentry_sdk.utils import HAS_CHAINED_EXCEPTIONS
13+
from sentry_sdk.utils import HAS_CHAINED_EXCEPTIONS, executing
1414

1515
if PY2:
1616
# Importing ABCs from collections is deprecated, and will stop working in 3.8
@@ -224,10 +224,14 @@ def bar():
224224
(event,) = events
225225
(thread,) = event["threads"]["values"]
226226
functions = [x["function"] for x in thread["stacktrace"]["frames"]]
227-
assert functions[-2:] == [
228-
"test_attach_stacktrace_enabled.<locals>.foo",
229-
"test_attach_stacktrace_enabled.<locals>.bar",
230-
]
227+
228+
if executing:
229+
assert functions[-2:] == [
230+
"test_attach_stacktrace_enabled.<locals>.foo",
231+
"test_attach_stacktrace_enabled.<locals>.bar",
232+
]
233+
else:
234+
assert functions[-2:] == ["foo", "bar"]
231235

232236

233237
def test_attach_stacktrace_enabled_no_locals():

tox.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ envlist =
2020
# {py2.7}-django-{1.11}
2121
# {py2.7,py3.7}-django-{1.11,2.2}
2222

23-
{pypy,py2.7}-django-{1.6,1.7}
23+
py{2.7,3.4,3.5,3.6,3.7,3.8,py}-executing
24+
25+
{pypy,py2.7}-django-{1.6,1.7}{-executing,}
2426
{pypy,py2.7,py3.5}-django-{1.8,1.9,1.10,1.11}
2527
{py3.5,py3.6,py3.7}-django-{2.0,2.1}
2628
{py3.7,py3.8}-django-{2.2,3.0,dev}
@@ -181,6 +183,8 @@ deps =
181183

182184
py3.8: hypothesis
183185

186+
executing: executing
187+
184188
setenv =
185189
PYTHONDONTWRITEBYTECODE=1
186190
TESTPATH=tests

0 commit comments

Comments
 (0)