Repository navigation
Fix Django test discovery/execution crash from incompatible default unittest args - #26285
Open
Jim Hall (biggdawg320) wants to merge 1 commit into
Open
Jim Hall (biggdawg320) wants to merge 1 commit into
Jim Hall (biggdawg320) wants to merge 1 commit into
Conversation
Django test discovery/execution crashed with "argument -v/--verbosity: expected one argument" because the raw unittest-style argv the extension sends by default (-v -s . -p test*.py) was forwarded unmodified to `manage.py test`. unittest's -v/-q are value-less flags while Django's -v/--verbosity requires an explicit numeric value, and -s/--start-directory has no Django equivalent since Django discovers tests across installed apps rather than a start directory. django_handler.py now adapts only those two incompatibilities before building the manage.py command: -s/--start-directory (and its value) is dropped, and -v/--verbose or -q/--quiet are translated into an explicit "-v 2"/"-v 0". Everything else -- -p/--pattern, -t/--top-level-directory, --failfast, and any Django-specific flags a user adds to unittestArgs (--keepdb, --settings, etc.) -- is passed through unchanged, for both discovery and execution. Co-Authored-By: Claude <noreply@anthropic.com>
|
Jim Hall (@biggdawg320) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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.
Django test discovery and execution failed with
manage.py test: error: argument -v/--verbosity: expected one argumentbecause the extension's default unittest discovery arguments (-v -s . -p test*.py) were forwarded as-is tomanage.py test, even though Django's-v/--verbosityrequires an explicit value and has no-s/--start-directoryequivalent.django_handler.py's_to_manage_py_argsnow adapts only those two incompatible flags (dropping-s/--start-directory, translating-v/-qinto an explicit-v 2/-v 0) while passing every other argument through unchanged, so user-supplied-p,-t,--failfast, and Django-specific options like--keepdbkeep working as before. Added end-to-end regression tests intest_discovery.pyandtest_execution.py(plus a small extension todjango_test_execution_script.pyto forward extra args) that drive the real discovery/execution scripts with the default args and assert on the resulting payload.Fixes #24991
Testing
python_files/tests/unittestadapter/test_discovery.py) that fails on the current code and passes with this change.python python_files/tests/run_all.py python_files/tests/unittestadapter --no-functionalThis change was drafted with AI assistance (Claude) and verified against the project's own test suite before submission.