From b205cd2fc34959fa77939eb661a370a358e0ee2d Mon Sep 17 00:00:00 2001 From: Ahmed Etefy Date: Mon, 31 May 2021 10:32:35 +0200 Subject: [PATCH 01/10] fix(ci): Pin trytond werkzeug dependency to Werkzeug<2.0 --- tox.ini | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index 40e322650c..00c8da073c 100644 --- a/tox.ini +++ b/tox.ini @@ -201,7 +201,7 @@ deps = trytond-5.0: trytond>=5.0,<5.1 trytond-4.6: trytond>=4.6,<4.7 - trytond-4.8: werkzeug<1.0 + trytond-{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 redis: fakeredis @@ -298,9 +298,6 @@ commands = ; https://github.com/pytest-dev/pytest/issues/5532 {py3.5,py3.6,py3.7,py3.8,py3.9}-flask-{0.10,0.11,0.12}: pip install pytest<5 - ; trytond tries to import werkzeug.contrib - trytond-5.0: pip install werkzeug<1.0 - py.test {env:TESTPATH} {posargs} [testenv:linters] From c3ac7d45684c370570156202d8dfcd9dbe22f866 Mon Sep 17 00:00:00 2001 From: Ahmed Etefy Date: Tue, 1 Jun 2021 11:29:26 +0200 Subject: [PATCH 02/10] Pinned Wekzeug frequence for flask --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 00c8da073c..60b6dd113d 100644 --- a/tox.ini +++ b/tox.ini @@ -297,6 +297,7 @@ commands = ; https://github.com/pytest-dev/pytest/issues/5532 {py3.5,py3.6,py3.7,py3.8,py3.9}-flask-{0.10,0.11,0.12}: pip install pytest<5 + {py3.6,py3.7,py3.8,py3.9}-flask-{0.11}: pip install Werkzeug<2 py.test {env:TESTPATH} {posargs} From f6a9658dbb2544fd9619e3aa6f028f6e1ee81505 Mon Sep 17 00:00:00 2001 From: Ahmed Etefy Date: Tue, 1 Jun 2021 16:27:51 +0200 Subject: [PATCH 03/10] Pinned pytest-django --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 60b6dd113d..7fd4a9f9d9 100644 --- a/tox.ini +++ b/tox.ini @@ -101,7 +101,7 @@ deps = django-{1.6,1.7}: pytest-django<3.0 django-{1.8,1.9,1.10,1.11,2.0,2.1}: pytest-django<4.0 - django-{2.2,3.0,3.1}: pytest-django>=4.0 + django-{2.2,3.0,3.1}: pytest-django>=4.0,<4.3 django-dev: git+https://github.com/pytest-dev/pytest-django#egg=pytest-django django-1.6: Django>=1.6,<1.7 From a4d2dff165b08a3f7797384ad9b1eaf16ae9149c Mon Sep 17 00:00:00 2001 From: Ahmed Etefy Date: Tue, 1 Jun 2021 16:59:22 +0200 Subject: [PATCH 04/10] Fixed missing DB django tests issue --- tests/integrations/django/test_basic.py | 4 ++++ tox.ini | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index 9341dc238d..fe6a1a04c9 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -258,6 +258,8 @@ def test_sql_dict_query_params(sentry_init, capture_events): if "postgres" not in connections: pytest.skip("postgres tests disabled") + pytest.mark.django_db.databases.append("postgres") + sql = connections["postgres"].cursor() events = capture_events() @@ -303,6 +305,7 @@ def test_sql_psycopg2_string_composition(sentry_init, capture_events, query): pytest.skip("postgres tests disabled") import psycopg2.sql + pytest.mark.django_db.databases.append("postgres") sql = connections["postgres"].cursor() @@ -336,6 +339,7 @@ def test_sql_psycopg2_placeholders(sentry_init, capture_events): pytest.skip("postgres tests disabled") import psycopg2.sql + pytest.mark.django_db.databases.append("postgres") sql = connections["postgres"].cursor() diff --git a/tox.ini b/tox.ini index 7fd4a9f9d9..14a5e9409b 100644 --- a/tox.ini +++ b/tox.ini @@ -101,7 +101,8 @@ deps = django-{1.6,1.7}: pytest-django<3.0 django-{1.8,1.9,1.10,1.11,2.0,2.1}: pytest-django<4.0 - django-{2.2,3.0,3.1}: pytest-django>=4.0,<4.3 + django-{2.2,3.0,3.1}: pytest-django>=4.0 + django-{2.2,3.0,3.1}: Werkzeug<2.0 django-dev: git+https://github.com/pytest-dev/pytest-django#egg=pytest-django django-1.6: Django>=1.6,<1.7 From fadddd5decaf1b3e0099bef1ee0824231cb9b1bf Mon Sep 17 00:00:00 2001 From: sentry-bot Date: Tue, 1 Jun 2021 15:00:18 +0000 Subject: [PATCH 05/10] fix: Formatting --- tests/integrations/django/test_basic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index fe6a1a04c9..4dbf4d5eb3 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -305,6 +305,7 @@ def test_sql_psycopg2_string_composition(sentry_init, capture_events, query): pytest.skip("postgres tests disabled") import psycopg2.sql + pytest.mark.django_db.databases.append("postgres") sql = connections["postgres"].cursor() @@ -339,6 +340,7 @@ def test_sql_psycopg2_placeholders(sentry_init, capture_events): pytest.skip("postgres tests disabled") import psycopg2.sql + pytest.mark.django_db.databases.append("postgres") sql = connections["postgres"].cursor() From 8c058fdf6f318e3c9055bd18678ddf9953d13bac Mon Sep 17 00:00:00 2001 From: Ahmed Etefy Date: Tue, 1 Jun 2021 17:23:28 +0200 Subject: [PATCH 06/10] Allowed database access to postgres database in django tests --- tests/integrations/django/test_basic.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index fe6a1a04c9..ff8894c49a 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -245,7 +245,7 @@ def test_sql_queries(sentry_init, capture_events, with_integration): @pytest.mark.forked -@pytest.mark.django_db +@pytest.mark.django_db(databases="__all__") def test_sql_dict_query_params(sentry_init, capture_events): sentry_init( integrations=[DjangoIntegration()], @@ -258,8 +258,6 @@ def test_sql_dict_query_params(sentry_init, capture_events): if "postgres" not in connections: pytest.skip("postgres tests disabled") - pytest.mark.django_db.databases.append("postgres") - sql = connections["postgres"].cursor() events = capture_events() @@ -292,7 +290,7 @@ def test_sql_dict_query_params(sentry_init, capture_events): ], ) @pytest.mark.forked -@pytest.mark.django_db +@pytest.mark.django_db(databases="__all__") def test_sql_psycopg2_string_composition(sentry_init, capture_events, query): sentry_init( integrations=[DjangoIntegration()], @@ -305,7 +303,6 @@ def test_sql_psycopg2_string_composition(sentry_init, capture_events, query): pytest.skip("postgres tests disabled") import psycopg2.sql - pytest.mark.django_db.databases.append("postgres") sql = connections["postgres"].cursor() @@ -326,7 +323,7 @@ def test_sql_psycopg2_string_composition(sentry_init, capture_events, query): @pytest.mark.forked -@pytest.mark.django_db +@pytest.mark.django_db(databases="__all__") def test_sql_psycopg2_placeholders(sentry_init, capture_events): sentry_init( integrations=[DjangoIntegration()], @@ -339,7 +336,6 @@ def test_sql_psycopg2_placeholders(sentry_init, capture_events): pytest.skip("postgres tests disabled") import psycopg2.sql - pytest.mark.django_db.databases.append("postgres") sql = connections["postgres"].cursor() From cea84e69cc95a501adfd0d50c7d14607cbb1b8ce Mon Sep 17 00:00:00 2001 From: Ahmed Etefy Date: Tue, 1 Jun 2021 18:07:15 +0200 Subject: [PATCH 07/10] Added hack to set the appropriate db decorator --- tests/integrations/django/test_basic.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index ff8894c49a..c0ca9ad41d 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -1,6 +1,7 @@ from __future__ import absolute_import import pytest +import pytest_django import json from werkzeug.test import Client @@ -21,6 +22,15 @@ from tests.integrations.django.myapp.wsgi import application +# Hack to prevent from experimental feature introduced in version `4.3.0` in `pytest-django` that +# requires explicit database allow from failing the test +pytest_mark_django_db_decorator = pytest.mark.django_db +try: + if pytest_django.__version__ > (4, 2, 0): + pytest_mark_django_db_decorator = pytest.mark.django_db(database="__all__") +except AttributeError: + pass + @pytest.fixture def client(): @@ -245,7 +255,7 @@ def test_sql_queries(sentry_init, capture_events, with_integration): @pytest.mark.forked -@pytest.mark.django_db(databases="__all__") +@pytest_mark_django_db_decorator def test_sql_dict_query_params(sentry_init, capture_events): sentry_init( integrations=[DjangoIntegration()], @@ -290,7 +300,7 @@ def test_sql_dict_query_params(sentry_init, capture_events): ], ) @pytest.mark.forked -@pytest.mark.django_db(databases="__all__") +@pytest_mark_django_db_decorator def test_sql_psycopg2_string_composition(sentry_init, capture_events, query): sentry_init( integrations=[DjangoIntegration()], @@ -323,7 +333,7 @@ def test_sql_psycopg2_string_composition(sentry_init, capture_events, query): @pytest.mark.forked -@pytest.mark.django_db(databases="__all__") +@pytest_mark_django_db_decorator def test_sql_psycopg2_placeholders(sentry_init, capture_events): sentry_init( integrations=[DjangoIntegration()], From 832ce55afef0dd88ed5c47d14a396eb57c0d3142 Mon Sep 17 00:00:00 2001 From: Ahmed Etefy Date: Tue, 1 Jun 2021 18:30:55 +0200 Subject: [PATCH 08/10] Converted string version into tuple for comparison --- tests/integrations/django/test_basic.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index c0ca9ad41d..9ecf3bade5 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -26,8 +26,9 @@ # requires explicit database allow from failing the test pytest_mark_django_db_decorator = pytest.mark.django_db try: - if pytest_django.__version__ > (4, 2, 0): - pytest_mark_django_db_decorator = pytest.mark.django_db(database="__all__") + pytest_version = tuple(map(int, pytest_django.__version__.split('.'))) + if pytest_version > (4, 2, 0): + pytest_mark_django_db_decorator = pytest.mark.django_db(databases="__all__") except AttributeError: pass From d8b8f32037c1dd8596249baf938c79cadc98c08d Mon Sep 17 00:00:00 2001 From: sentry-bot Date: Tue, 1 Jun 2021 16:31:34 +0000 Subject: [PATCH 09/10] fix: Formatting --- tests/integrations/django/test_basic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index 9ecf3bade5..103f9a57de 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -26,7 +26,7 @@ # requires explicit database allow from failing the test pytest_mark_django_db_decorator = pytest.mark.django_db try: - pytest_version = tuple(map(int, pytest_django.__version__.split('.'))) + pytest_version = tuple(map(int, pytest_django.__version__.split("."))) if pytest_version > (4, 2, 0): pytest_mark_django_db_decorator = pytest.mark.django_db(databases="__all__") except AttributeError: From 56a48250f0a89a2ffbc094ddc5345e3e6aaedf1a Mon Sep 17 00:00:00 2001 From: Ahmed Etefy Date: Tue, 1 Jun 2021 18:52:09 +0200 Subject: [PATCH 10/10] Handled dev versions of pytest_django in hack --- tests/integrations/django/test_basic.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index 9ecf3bade5..e295f3b189 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -29,6 +29,9 @@ pytest_version = tuple(map(int, pytest_django.__version__.split('.'))) if pytest_version > (4, 2, 0): pytest_mark_django_db_decorator = pytest.mark.django_db(databases="__all__") +except ValueError: + if "dev" in pytest_django: + pytest_mark_django_db_decorator = pytest.mark.django_db(databases="__all__") except AttributeError: pass