Skip to content

test: Fix DeprecationWarning and RuntimeWarning emitted by unit tests#1960

Draft
vdusek wants to merge 1 commit into
masterfrom
test/fix-unit-test-warnings
Draft

test: Fix DeprecationWarning and RuntimeWarning emitted by unit tests#1960
vdusek wants to merge 1 commit into
masterfrom
test/fix-unit-test-warnings

Conversation

@vdusek

@vdusek vdusek commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Description

The unit-test jobs in CI emit two kinds of warnings:

  • DeprecationWarning: This process is multi-threaded, use of fork() may lead to deadlocks in the child from multiprocessing on Linux with Python 3.12+. It is triggered by test_system.py (explicit fork context), the ProcessPoolExecutor tests in test_basic_crawler.py, and the proxy.py acceptor processes used by the proxy fixtures, because the default start method on Linux up to Python 3.13 is fork and the pytest process is multi-threaded (uvicorn test server thread, xdist).
  • RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited in test_global_and_local_event_manager_in_crawler_run, which called an AsyncMock without awaiting it.

Changes:

  • Set the spawn start method in tests/unit/conftest.py for all subprocesses created in unit tests. This also aligns Python <= 3.13 runs with Python 3.14, which no longer defaults to fork. proxy.py has no API for choosing a start method, so the default has to be set globally.
  • Refactor the shared-memory estimation test in test_system.py to module-level (picklable) child functions running under an explicit spawn context instead of fork.
  • Replace the unawaited AsyncMock with a plain Mock, since the handler only records call arguments synchronously.

The full unit suite passes with an empty warnings summary.

Use the spawn start method for all subprocesses created in unit tests, since forking the multi-threaded pytest process is deprecated on Python 3.12+, and replace an unawaited AsyncMock call with a plain Mock.
@vdusek vdusek added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. labels Jun 11, 2026
@vdusek vdusek self-assigned this Jun 11, 2026
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.95%. Comparing base (3fd5ace) to head (6fc81cd).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1960      +/-   ##
==========================================
- Coverage   93.00%   92.95%   -0.06%     
==========================================
  Files         167      167              
  Lines       11737    11737              
==========================================
- Hits        10916    10910       -6     
- Misses        821      827       +6     
Flag Coverage Δ
unit 92.95% <ø> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants