Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

test(django): Remove @pytest.mark.forked dependency from Django integration tests

Offen
#6,411 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
52/100
Issue-Typ
Refactoring
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
django, python
Bereich
backend, testing-qa

Rechercherichtung

Beginne mit der sentry_init-Fixture und DjangoIntegration.setup_once und prüfe anschließend tests/integrations/django/test_basic.py, test_cache_module.py, test_db_query_data.py, test_db_transactions.py und test_data_scrubbing.py. Entferne die forked-Marker eine Datei nach der anderen, füge eine explizite Isolation von Django und dem Integrationszustand hinzu und führe die betroffenen Tests nach jeder Migration aus. Fertig ist die Arbeit, wenn alle aufgeführten Tests ohne pytest-forked bestehen und zwischen den Tests keine Zustandslecks auftreten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Python Tests

Background

The Django integration test suite uses @pytest.mark.forked (via pytest-forked) on 52 tests across 5 files to isolate global state. This dates back to #522 ("Less boxed testing") and was a pragmatic substitute for proper teardown.

Problem

pytest-forked is actively harmful in some scenarios:

  • Python 3.12 + asyncio + GitHub Actions: Forking a multi-threaded process and then running an asyncio loop in the child causes silent hangs (the loop inherits dead threads). This consumed the full 30-minute CI budget on the Django ASGI tests until #6410 dropped forked from those 10 tests.
  • Slow: Fork-per-test multiplies suite runtime.
  • Hides real isolation bugs: Tests pass under fork but would fail under proper sequential execution, masking integration setup that isn't idempotent.

Goal

Remove @pytest.mark.forked from every test under tests/integrations/django/ and replace it with explicit isolation.

Proposed approach

  1. Extend (or autouse-wrap) the sentry_init fixture so the non-forked path also resets:
    • sentry_sdk.integrations._processed_integrations
    • sentry_sdk.integrations._installed_integrations
  2. Add a reset_django_state fixture that snapshots and restores:
    • settings.MIDDLEWARE
    • Django signal receivers (request_started, request_finished, etc.)
    • Anything else DjangoIntegration.setup_once connects
  3. Audit DjangoIntegration.setup_once (and submodule patches under sentry_sdk/integrations/django/) for non-idempotent module-level patching.
  4. Migrate test files one at a time: drop the marker, run, fix the resulting leaks, repeat.

Current state

Files still using @pytest.mark.forked under tests/integrations/django/ (count via grep -rc):

  • test_basic.py (13)
  • test_cache_module.py (14)
  • test_db_query_data.py (10)
  • test_db_transactions.py (12)
  • test_data_scrubbing.py (3)

The ASGI subset (tests/integrations/django/asgi/test_asgi.py) was removed in #6410.

Vorherrschende Sprache
Python
Sterne
2.2k
Forks
680
Ø Merge
1 T. 3 Std.
Gemergte PRs (30 T.)
264

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus getsentry/sentry-python

Alle Issues in getsentry/sentry-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.