test(django): Remove @pytest.mark.forked dependency from Django integration tests
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- backend, testing-qa
Hướng nghiên cứu
Bắt đầu với fixture sentry_init và DjangoIntegration.setup_once, sau đó kiểm tra tests/integrations/django/test_basic.py, test_cache_module.py, test_db_query_data.py, test_db_transactions.py và test_data_scrubbing.py. Xóa các marker forked từng file một, thêm cơ chế cô lập tường minh cho Django và trạng thái tích hợp, rồi chạy các test bị ảnh hưởng sau mỗi lần migration. Công việc được hoàn tất khi tất cả test được liệt kê đều pass mà không cần pytest-forked và không có rò rỉ trạng thái giữa các test.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 2.2k
- Fork
- 672
- Merge trung bình
- 22 giờ 47 phút
- Pull request đã merge (30 ngày)
- 224
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của getsentry/sentry-python
-
Python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
getsentry/sentry-python#7569 · 1 bình luận ·
-
Python
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
getsentry/sentry-python#7568 · 2 bình luận ·
-
Python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
getsentry/sentry-python#7567 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getsentry/sentry-python#7543 · 2 bình luận · 1 người được giao ·
-
Python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
getsentry/sentry-python#6992 · 1 bình luận ·
Tất cả issue của getsentry/sentry-python
Issue tương tự
-
bug confirmed issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
open-webui/open-webui#30750 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100