From e55e48e0780f023af627b1a85f36f8a6272eb75e Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 17 Jan 2023 15:16:47 +0100 Subject: [PATCH] Fixed tests --- .../django/test_data_scrubbing.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/integrations/django/test_data_scrubbing.py b/tests/integrations/django/test_data_scrubbing.py index 13b470a7a4..c0ab14ae63 100644 --- a/tests/integrations/django/test_data_scrubbing.py +++ b/tests/integrations/django/test_data_scrubbing.py @@ -1,4 +1,6 @@ +from functools import partial import pytest +import pytest_django from werkzeug.test import Client @@ -12,11 +14,31 @@ from django.core.urlresolvers import reverse +# 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 = partial(pytest.mark.django_db) +try: + pytest_version = tuple(map(int, pytest_django.__version__.split("."))) + if pytest_version > (4, 2, 0): + pytest_mark_django_db_decorator = partial( + pytest.mark.django_db, databases="__all__" + ) +except ValueError: + if "dev" in pytest_django.__version__: + pytest_mark_django_db_decorator = partial( + pytest.mark.django_db, databases="__all__" + ) +except AttributeError: + pass + + @pytest.fixture def client(): return Client(application) +@pytest.mark.forked +@pytest_mark_django_db_decorator() def test_scrub_django_session_cookies_removed( sentry_init, client, @@ -33,6 +55,8 @@ def test_scrub_django_session_cookies_removed( assert "cookies" not in event["request"] +@pytest.mark.forked +@pytest_mark_django_db_decorator() def test_scrub_django_session_cookies_filtered( sentry_init, client, @@ -53,6 +77,8 @@ def test_scrub_django_session_cookies_filtered( } +@pytest.mark.forked +@pytest_mark_django_db_decorator() def test_scrub_django_custom_session_cookies_filtered( sentry_init, client,