test: Fix DeprecationWarning and RuntimeWarning emitted by unit tests#1960
Draft
vdusek wants to merge 1 commit into
Draft
test: Fix DeprecationWarning and RuntimeWarning emitted by unit tests#1960vdusek wants to merge 1 commit into
vdusek wants to merge 1 commit into
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 childfrommultiprocessingon Linux with Python 3.12+. It is triggered bytest_system.py(explicitforkcontext), theProcessPoolExecutortests intest_basic_crawler.py, and theproxy.pyacceptor processes used by the proxy fixtures, because the default start method on Linux up to Python 3.13 isforkand the pytest process is multi-threaded (uvicorn test server thread, xdist).RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaitedintest_global_and_local_event_manager_in_crawler_run, which called anAsyncMockwithout awaiting it.Changes:
spawnstart method intests/unit/conftest.pyfor all subprocesses created in unit tests. This also aligns Python <= 3.13 runs with Python 3.14, which no longer defaults tofork.proxy.pyhas no API for choosing a start method, so the default has to be set globally.test_system.pyto module-level (picklable) child functions running under an explicitspawncontext instead offork.AsyncMockwith a plainMock, since the handler only records call arguments synchronously.The full unit suite passes with an empty warnings summary.