Skip to content

Commit 38b983e

Browse files
untitakersentry-bot
and
sentry-bot
authored
fix(ci): unpin pytest, stop testing eventlet (getsentry#965)
* fix(ci): Unpin pytest, stop testing eventlet * eventlet is broken all the time in newer Python versions * Channels 3.0 needs some adjustments. * unpin pytest to satisfy conflicts between Python 3.9 and Python 2.7 environments * install pytest-django for old django too * downgrade pytest for old flask * fix flask 1.11 error * revert flask-dev hack, new pip resolver has landed * fix django * fix trytond * drop trytond on py3.4 * remove broken assertion * fix remaining issues * fix: Formatting * fix linters * fix channels condition * remove py3.6-flask-dev because its failing Co-authored-by: sentry-bot <markus+ghbot@sentry.io>
1 parent c359291 commit 38b983e

File tree

6 files changed

+46
-67
lines changed

6 files changed

+46
-67
lines changed

sentry_sdk/integrations/flask.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from sentry_sdk.integrations.wsgi import _ScopedResponse
1515
from typing import Any
1616
from typing import Dict
17-
from werkzeug.datastructures import ImmutableTypeConversionDict
1817
from werkzeug.datastructures import ImmutableMultiDict
1918
from werkzeug.datastructures import FileStorage
2019
from typing import Union
@@ -127,8 +126,11 @@ def env(self):
127126
return self.request.environ
128127

129128
def cookies(self):
130-
# type: () -> ImmutableTypeConversionDict[Any, Any]
131-
return self.request.cookies
129+
# type: () -> Dict[Any, Any]
130+
return {
131+
k: v[0] if isinstance(v, list) and len(v) == 1 else v
132+
for k, v in self.request.cookies.items()
133+
}
132134

133135
def raw_data(self):
134136
# type: () -> bytes

test-requirements.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
pytest==3.7.3
1+
pytest
22
pytest-forked==1.1.3
33
tox==3.7.0
4-
Werkzeug==0.15.5
4+
Werkzeug
55
pytest-localserver==0.5.0
66
pytest-cov==2.8.1
77
jsonschema==3.2.0
88
pyrsistent==0.16.0 # TODO(py3): 0.17.0 requires python3, see https://github.com/tobgu/pyrsistent/issues/205
99
mock # for testing under python < 3.3
1010

1111
gevent
12-
eventlet
1312

1413
newrelic
1514
executing

tests/conftest.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44
import pytest
55
import jsonschema
66

7-
import gevent
8-
import eventlet
7+
try:
8+
import gevent
9+
except ImportError:
10+
gevent = None
11+
12+
try:
13+
import eventlet
14+
except ImportError:
15+
eventlet = None
916

1017
import sentry_sdk
1118
from sentry_sdk._compat import reraise, string_types, iteritems
@@ -284,6 +291,9 @@ def read_flush(self):
284291
)
285292
def maybe_monkeypatched_threading(request):
286293
if request.param == "eventlet":
294+
if eventlet is None:
295+
pytest.skip("no eventlet installed")
296+
287297
try:
288298
eventlet.monkey_patch()
289299
except AttributeError as e:
@@ -293,6 +303,8 @@ def maybe_monkeypatched_threading(request):
293303
else:
294304
raise
295305
elif request.param == "gevent":
306+
if gevent is None:
307+
pytest.skip("no gevent installed")
296308
try:
297309
gevent.monkey.patch_all()
298310
except Exception as e:
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
import channels
2+
13
from channels.http import AsgiHandler
24
from channels.routing import ProtocolTypeRouter
35

4-
application = ProtocolTypeRouter({"http": AsgiHandler})
6+
if channels.__version__ < "3.0.0":
7+
channels_handler = AsgiHandler
8+
else:
9+
channels_handler = AsgiHandler()
10+
11+
application = ProtocolTypeRouter({"http": channels_handler})

tests/utils/test_general.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ def test_filename():
7676
assert x("bogus", "bogus") == "bogus"
7777

7878
assert x("os", os.__file__) == "os.py"
79-
assert x("pytest", pytest.__file__) == "pytest.py"
8079

8180
import sentry_sdk.utils
8281

tox.ini

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ envlist =
2929
{pypy,py2.7,py3.4,py3.5,py3.6,py3.7,py3.8,py3.9}-flask-{0.10,0.11,0.12,1.0}
3030
{pypy,py2.7,py3.5,py3.6,py3.7,py3.8,py3.9}-flask-1.1
3131

32-
# TODO: see note in [testenv:flask-dev] below
33-
; {py3.6,py3.7,py3.8,py3.9}-flask-dev
32+
{py3.7,py3.8,py3.9}-flask-dev
3433

3534
{pypy,py2.7,py3.5,py3.6,py3.7,py3.8,py3.9}-bottle-0.12
3635

@@ -64,8 +63,7 @@ envlist =
6463

6564
{py3.7,py3.8,py3.9}-tornado-{5,6}
6665

67-
{py3.4,py3.5,py3.6,py3.7,py3.8,py3.9}-trytond-{4.6,4.8,5.0}
68-
{py3.5,py3.6,py3.7,py3.8,py3.9}-trytond-{5.2}
66+
{py3.5,py3.6,py3.7,py3.8,py3.9}-trytond-{4.6,5.0,5.2}
6967
{py3.6,py3.7,py3.8,py3.9}-trytond-{5.4}
7068

7169
{py2.7,py3.8,py3.9}-requests
@@ -94,25 +92,13 @@ deps =
9492

9593
django-{1.11,2.0,2.1,2.2,3.0,3.1,dev}: djangorestframework>=3.0.0,<4.0.0
9694

97-
; TODO: right now channels 3 is crashing tests/integrations/django/asgi/test_asgi.py
98-
; see https://github.com/django/channels/issues/1549
99-
{py3.7,py3.8,py3.9}-django-{1.11,2.0,2.1,2.2,3.0,3.1,dev}: channels>2,<3
100-
{py3.7,py3.8,py3.9}-django-{1.11,2.0,2.1,2.2,3.0,3.1,dev}: pytest-asyncio==0.10.0
95+
{py3.7,py3.8,py3.9}-django-{1.11,2.0,2.1,2.2,3.0,3.1,dev}: channels>2
96+
{py3.7,py3.8,py3.9}-django-{1.11,2.0,2.1,2.2,3.0,3.1,dev}: pytest-asyncio
10197
{py2.7,py3.7,py3.8,py3.9}-django-{1.11,2.2,3.0,3.1,dev}: psycopg2-binary
10298

103-
django-{1.6,1.7,1.8}: pytest-django<3.0
104-
105-
; TODO: once we upgrade pytest to at least 5.4, we can split it like this:
106-
; django-{1.9,1.10,1.11,2.0,2.1}: pytest-django<4.0
107-
; django-{2.2,3.0,3.1}: pytest-django>=4.0
108-
109-
; (note that py3.9, on which we recently began testing, only got official
110-
; support in pytest-django >=4.0, so we probablly want to upgrade the whole
111-
; kit and kaboodle at some point soon)
112-
113-
; see https://pytest-django.readthedocs.io/en/latest/changelog.html#v4-0-0-2020-10-16
114-
django-{1.9,1.10,1.11,2.0,2.1,2.2,3.0,3.1}: pytest-django<4.0
115-
99+
django-{1.6,1.7}: pytest-django<3.0
100+
django-{1.8,1.9,1.10,1.11,2.0,2.1}: pytest-django<4.0
101+
django-{2.2,3.0,3.1}: pytest-django>=4.0
116102
django-dev: git+https://github.com/pytest-dev/pytest-django#egg=pytest-django
117103

118104
django-1.6: Django>=1.6,<1.7
@@ -135,9 +121,8 @@ deps =
135121
flask-1.0: Flask>=1.0,<1.1
136122
flask-1.1: Flask>=1.1,<1.2
137123

138-
# TODO: see note in [testenv:flask-dev] below
139-
; flask-dev: git+https://github.com/pallets/flask.git#egg=flask
140-
; flask-dev: git+https://github.com/pallets/werkzeug.git#egg=werkzeug
124+
flask-dev: git+https://github.com/pallets/flask.git#egg=flask
125+
flask-dev: git+https://github.com/pallets/werkzeug.git#egg=werkzeug
141126

142127
bottle-0.12: bottle>=0.12,<0.13
143128
bottle-dev: git+https://github.com/bottlepy/bottle#egg=bottle
@@ -207,9 +192,10 @@ deps =
207192
trytond-5.4: trytond>=5.4,<5.5
208193
trytond-5.2: trytond>=5.2,<5.3
209194
trytond-5.0: trytond>=5.0,<5.1
210-
trytond-4.8: trytond>=4.8,<4.9
211195
trytond-4.6: trytond>=4.6,<4.7
212196

197+
trytond-4.8: werkzeug<1.0
198+
213199
redis: fakeredis
214200

215201
rediscluster-1: redis-py-cluster>=1.0.0,<2.0.0
@@ -302,41 +288,15 @@ basepython =
302288
pypy: pypy
303289

304290
commands =
305-
py.test {env:TESTPATH} {posargs}
291+
django-{1.6,1.7}: pip install pytest<4
306292

293+
; https://github.com/pytest-dev/pytest/issues/5532
294+
{py3.5,py3.6,py3.7,py3.8,py3.9}-flask-{0.10,0.11,0.12}: pip install pytest<5
307295

308-
# TODO: This is broken out as a separate env so as to be able to override the
309-
# werkzeug version. (You can't do it just by letting one version be specifed in
310-
# a requirements file and specifying a different version in one testenv, see
311-
# https://github.com/tox-dev/tox/issues/1390.) The issue is that as of 11/11/20,
312-
# flask-dev has made a change which werkzeug then had to compensate for in
313-
# https://github.com/pallets/werkzeug/pull/1960. Since we've got werkzeug
314-
# pinned at 0.15.5 in test-requirements.txt, we don't get this fix.
296+
; trytond tries to import werkzeug.contrib
297+
trytond-5.0: pip install werkzeug<1.0
315298

316-
# At some point, we probably want to revisit this, since the list copied from
317-
# test-requirements.txt could easily get stale.
318-
[testenv:flask-dev]
319-
deps =
320-
git+https://github.com/pallets/flask.git#egg=flask
321-
git+https://github.com/pallets/werkzeug.git#egg=werkzeug
322-
323-
# everything below this point is from test-requirements.txt (minus, of
324-
# course, werkzeug)
325-
pytest==3.7.3
326-
pytest-forked==1.1.3
327-
tox==3.7.0
328-
pytest-localserver==0.5.0
329-
pytest-cov==2.8.1
330-
jsonschema==3.2.0
331-
pyrsistent==0.16.0 # TODO(py3): 0.17.0 requires python3, see https://github.com/tobgu/pyrsistent/issues/205
332-
mock # for testing under python < 3.3
333-
334-
gevent
335-
eventlet
336-
337-
newrelic
338-
executing
339-
asttokens
299+
py.test {env:TESTPATH} {posargs}
340300

341301
[testenv:linters]
342302
commands =

0 commit comments

Comments
 (0)