Enhance TestmonXdistSync registration and initialization #260
+207
−5
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
Fixes #259
This PR fixes the
sqlite3.OperationalError: database is lockederror that occurs when using--testmon --testmon-nocollectwith pytest-xdist.Problem
When
--testmon-nocollectis used,TestmonXdistSyncwas not registered because it was inside theif should_collect:block. This meant:testmon_exec_idfrom the controller viapytest_configure_nodehookTestmonData.for_local_run()(write mode) instead offor_worker()(read-only)Solution
TestmonXdistSyncregistration to theif should_select or should_collect:block, so it's registered whenever testmon is activeshould_collectparameter toTestmonXdistSync.__init__()to track whether collection is activesync_db_fs_tests()inpytest_xdist_node_collection_finished()when in nocollect mode (since DB is read-only)Changes
testmon/pytest_testmon.pyregister_plugins()to registerTestmonXdistSyncin theif should_select or should_collect:blockshould_collectparameter toTestmonXdistSync.__init__()pytest_xdist_node_collection_finished()to checkself._should_collectbefore syncingtests/test_xdist_integration.py(new file)Testing
Backward Compatibility
This change is fully backward compatible:
should_collectparameter defaults toTrue--testmon-nocollectis not usedChecklist