test(django): Remove @pytest.mark.forked dependency from Django integration tests
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 52/100
- Tipo de issue
- Refatoração
- Clareza
- Razoavelmente clara
- Status de atividade
- Pouca atividade
- Domínio
- backend, testing-qa
Direção de pesquisa
Comece com a fixture sentry_init e DjangoIntegration.setup_once e, em seguida, audite tests/integrations/django/test_basic.py, test_cache_module.py, test_db_query_data.py, test_db_transactions.py e test_data_scrubbing.py. Remova os marcadores forked, um arquivo por vez, adicione isolamento explícito do Django e do estado da integração e execute os testes afetados após cada migração. O trabalho estará concluído quando todos os testes listados passarem sem pytest-forked e não houver vazamentos de estado entre os testes.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
forkedfrom 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
- Extend (or autouse-wrap) the
sentry_initfixture so the non-forked path also resets:sentry_sdk.integrations._processed_integrationssentry_sdk.integrations._installed_integrations
- Add a
reset_django_statefixture that snapshots and restores:settings.MIDDLEWARE- Django signal receivers (
request_started,request_finished, etc.) - Anything else
DjangoIntegration.setup_onceconnects
- Audit
DjangoIntegration.setup_once(and submodule patches undersentry_sdk/integrations/django/) for non-idempotent module-level patching. - 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.
- Linguagem predominante
- Python
- Estrelas
- 2.2k
- Forks
- 672
- Merge médio
- 1d 13min
- PRs com merge (30d)
- 212
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de getsentry/sentry-python
-
Waiting for: Product Owner
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
getsentry/sentry-python#7543 · 1 comentário ·
-
Python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
getsentry/sentry-python#6992 · 1 comentário ·
-
Improvement Python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
getsentry/sentry-python#6970 · 1 comentário ·
-
Bug Python
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
getsentry/sentry-python#6504 · 1 comentário ·
-
Improvement Python Spans
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
getsentry/sentry-python#5833 · 1 comentário ·
Todas as issues de getsentry/sentry-python
Issues semelhantes
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
use-agent-os/agent-os#3314 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
BasedHardware/omi#15662 · 1 comentário ·
-
documentation help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
AiursoftWeb/AnduinOS-2#19 ·