-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Proposed Fix for Optional Dependency Removal Bug (#10703) #10718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Test script to reproduce issue #10703 in poetry | ||
| # Expected: poetry remove pylint should succeed | ||
| from poetry.factory import Factory | ||
| from poetry.project.project import Project | ||
|
|
||
| # Simulated project setup | ||
| project = Project('test_project') | ||
| poetry = Factory().create_poetry(project) | ||
| poetry.add_dependency('pylint', {'optional': True}) | ||
| poetry.remove_dependency('pylint') | ||
| print("Optional dependency removed successfully.") | ||
|
Comment on lines
+10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Add assertions to verify the dependency was actually removed instead of relying on the absence of an exception and a print. Right now this test passes as long as no exception is raised and a message is printed. To make it a meaningful automated test, add an assertion that Suggested implementation: # Test script to reproduce issue #10703 in poetry
# Expected: poetry remove pylint should succeed
from poetry.factory import Factory
from poetry.project.project import Project
# Simulated project setup
project = Project('test_project')
poetry = Factory().create_poetry(project)
# Add optional dependency
poetry.add_dependency('pylint', {'optional': True})
# Sanity check that the dependency was added
assert 'pylint' in poetry.package.dependencies
# Remove the dependency
poetry.remove_dependency('pylint')
# Assert that the dependency was actually removed
assert 'pylint' not in poetry.package.dependenciesIf the Poetry API in your codebase exposes dependencies differently (for example via For example, you might need to change them to something like:
depending on how |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): The test should reflect the actual CLI behavior described in the PR (using
poetry remove), not just the internal API.The comment’s expectation is about the CLI (
poetry remove pylint), but this script only exercises internal classes. To reliably demonstrate the CLI bug is fixed, consider adding an integration/end-to-end test that runspoetry remove pylint(or equivalent) via the existing CLI test harness in a temporary project and asserts on exit code and output, matching the behavior described in issue #10703.Suggested implementation:
Depending on the existing test conventions in the Poetry codebase, you may want to:
tests/console/or similar) and adjust the module name accordingly.subprocess.runusage with Poetry's existing CLI test harness/runner (for example, aCommandTester,CliRunner, or repository-specific helper) if one is already used elsewhere forpoetryCLI tests.@pytest.mark.integration) with whatever marker or naming convention the project uses for end‑to‑end or CLI tests (e.g.@pytest.mark.e2e,@pytest.mark.cli, or none at all).poetryis invoked via a specific entry point (likepython -m poetryor a helper function), adjust thesubprocess.runarguments to match that convention.