Title: test(django): Remove @pytest.mark.forked dependency from Django integration tests · Issue #6411 · getsentry/sentry-python · GitHub
Open Graph Title: test(django): Remove @pytest.mark.forked dependency from Django integration tests · Issue #6411 · getsentry/sentry-python
X Title: test(django): Remove @pytest.mark.forked dependency from Django integration tests · Issue #6411 · getsentry/sentry-python
Description: 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 teardo...
Open Graph Description: 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 ...
X Description: 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"...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/6411
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test(django): Remove @pytest.mark.forked dependency from Django integration tests","articleBody":"## Background\n\nThe 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.\n\n## Problem\n\n`pytest-forked` is actively harmful in some scenarios:\n\n- **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.\n- **Slow:** Fork-per-test multiplies suite runtime.\n- **Hides real isolation bugs:** Tests pass under fork but would fail under proper sequential execution, masking integration setup that isn't idempotent.\n\n## Goal\n\nRemove `@pytest.mark.forked` from every test under `tests/integrations/django/` and replace it with explicit isolation.\n\n## Proposed approach\n\n1. Extend (or autouse-wrap) the `sentry_init` fixture so the non-forked path also resets:\n - `sentry_sdk.integrations._processed_integrations`\n - `sentry_sdk.integrations._installed_integrations`\n2. Add a `reset_django_state` fixture that snapshots and restores:\n - `settings.MIDDLEWARE`\n - Django signal receivers (`request_started`, `request_finished`, etc.)\n - Anything else `DjangoIntegration.setup_once` connects\n3. Audit `DjangoIntegration.setup_once` (and submodule patches under `sentry_sdk/integrations/django/`) for non-idempotent module-level patching.\n4. Migrate test files one at a time: drop the marker, run, fix the resulting leaks, repeat.\n\n## Current state\n\nFiles still using `@pytest.mark.forked` under `tests/integrations/django/` (count via `grep -rc`):\n\n- `test_basic.py` (13)\n- `test_cache_module.py` (14)\n- `test_db_query_data.py` (10)\n- `test_db_transactions.py` (12)\n- `test_data_scrubbing.py` (3)\n\nThe ASGI subset (`tests/integrations/django/asgi/test_asgi.py`) was removed in #6410.","author":{"url":"https://github.com/sl0thentr0py","@type":"Person","name":"sl0thentr0py"},"datePublished":"2026-05-26T13:08:32Z","url":"https://github.com/getsentry/sentry-python/issues/6411"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c1520903-7b14-b3ad-2856-ce8c986afebb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E464:34D742:40F9A9:57C225:6B008D31 |
| html-safe-nonce | 21a7a7d228b2f8c4d1e4f30d7e27bc218ba05d1a32abd72849ded4f244e1e312 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDY0OjM0RDc0Mjo0MEY5QTk6NTdDMjI1OjZCMDA4RDMxIiwidmlzaXRvcl9pZCI6IjQxNzI5NDEzMDI2MTYzMjk1MjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6f3b00d2bb26bb947f6cb9dc311685b9ca6edf29bcee14d71b8f994c95576cd7 |
| hovercard-subject-tag | issue:4524344742 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/6411/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6f94e65a143cb76e441956b5b4a7e5346f4fc5a83fcbbfde2bbc09dc72ab56fc/getsentry/sentry-python/issues/6411 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6f94e65a143cb76e441956b5b4a7e5346f4fc5a83fcbbfde2bbc09dc72ab56fc/getsentry/sentry-python/issues/6411 |
| og:image:alt | 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sl0thentr0py |
| hostname | github.com |
| expected-hostname | github.com |
| None | c710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | be616a2a6ec1c609d6e002896dff5352d5c5f28b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width