Skip to content

Commit b9c5cd4

Browse files
ahmedetefysentry-bot
and
sentry-bot
authored
fix(ci): Fix failing CI dependencies due to Werkzeug and pytest_django (getsentry#1124)
* fix(ci): Pin trytond werkzeug dependency to Werkzeug<2.0 * Pinned Wekzeug frequence for flask * Pinned pytest-django * Fixed missing DB django tests issue * fix: Formatting * Allowed database access to postgres database in django tests * Added hack to set the appropriate db decorator * Converted string version into tuple for comparison * fix: Formatting * Handled dev versions of pytest_django in hack Co-authored-by: sentry-bot <markus+ghbot@sentry.io>
1 parent be67071 commit b9c5cd4

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

tests/integrations/django/test_basic.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22

33
import pytest
4+
import pytest_django
45
import json
56

67
from werkzeug.test import Client
@@ -21,6 +22,19 @@
2122

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

25+
# Hack to prevent from experimental feature introduced in version `4.3.0` in `pytest-django` that
26+
# requires explicit database allow from failing the test
27+
pytest_mark_django_db_decorator = pytest.mark.django_db
28+
try:
29+
pytest_version = tuple(map(int, pytest_django.__version__.split(".")))
30+
if pytest_version > (4, 2, 0):
31+
pytest_mark_django_db_decorator = pytest.mark.django_db(databases="__all__")
32+
except ValueError:
33+
if "dev" in pytest_django.__version__:
34+
pytest_mark_django_db_decorator = pytest.mark.django_db(databases="__all__")
35+
except AttributeError:
36+
pass
37+
2438

2539
@pytest.fixture
2640
def client():
@@ -245,7 +259,7 @@ def test_sql_queries(sentry_init, capture_events, with_integration):
245259

246260

247261
@pytest.mark.forked
248-
@pytest.mark.django_db
262+
@pytest_mark_django_db_decorator
249263
def test_sql_dict_query_params(sentry_init, capture_events):
250264
sentry_init(
251265
integrations=[DjangoIntegration()],
@@ -290,7 +304,7 @@ def test_sql_dict_query_params(sentry_init, capture_events):
290304
],
291305
)
292306
@pytest.mark.forked
293-
@pytest.mark.django_db
307+
@pytest_mark_django_db_decorator
294308
def test_sql_psycopg2_string_composition(sentry_init, capture_events, query):
295309
sentry_init(
296310
integrations=[DjangoIntegration()],
@@ -323,7 +337,7 @@ def test_sql_psycopg2_string_composition(sentry_init, capture_events, query):
323337

324338

325339
@pytest.mark.forked
326-
@pytest.mark.django_db
340+
@pytest_mark_django_db_decorator
327341
def test_sql_psycopg2_placeholders(sentry_init, capture_events):
328342
sentry_init(
329343
integrations=[DjangoIntegration()],

tox.ini

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ deps =
104104
django-{1.6,1.7}: pytest-django<3.0
105105
django-{1.8,1.9,1.10,1.11,2.0,2.1}: pytest-django<4.0
106106
django-{2.2,3.0,3.1}: pytest-django>=4.0
107+
django-{2.2,3.0,3.1}: Werkzeug<2.0
107108
django-dev: git+https://github.com/pytest-dev/pytest-django#egg=pytest-django
108109

109110
django-1.6: Django>=1.6,<1.7
@@ -203,7 +204,7 @@ deps =
203204
trytond-5.0: trytond>=5.0,<5.1
204205
trytond-4.6: trytond>=4.6,<4.7
205206

206-
trytond-4.8: werkzeug<1.0
207+
trytond-{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0
207208

208209
redis: fakeredis
209210

@@ -303,9 +304,7 @@ commands =
303304

304305
; https://github.com/pytest-dev/pytest/issues/5532
305306
{py3.5,py3.6,py3.7,py3.8,py3.9}-flask-{0.10,0.11,0.12}: pip install pytest<5
306-
307-
; trytond tries to import werkzeug.contrib
308-
trytond-5.0: pip install werkzeug<1.0
307+
{py3.6,py3.7,py3.8,py3.9}-flask-{0.11}: pip install Werkzeug<2
309308

310309
py.test {env:TESTPATH} {posargs}
311310

0 commit comments

Comments
 (0)