Skip to content

test: cover unknown extras and missing packages - #11156

Open
CMGeorges wants to merge 1 commit into
python-poetry:mainfrom
CMGeorges:test/missing-extra-packages
Open

CMGeorges wants to merge 1 commit into
python-poetry:mainfrom
CMGeorges:test/missing-extra-packages

Conversation

@CMGeorges

Copy link
Copy Markdown

Relates-to: #3155

I added four cases to the existing get_extra_package_names parametrization. They check that unknown extras are ignored, that available packages are still returned when another requested package is missing, and that a missing transitive dependency does not discard its parent.

These tests protect the existing behavior; no production code changes are needed.

Validation on Linux with Python 3.12.14:

  • Full suite: 3,314 passed, 34 skipped, 2 xfailed, with no unexpected failures. I used env -u REQUESTS_CA_BUNDLE CC=gcc CXX=g++ .venv/bin/pytest -n 4 --cov=src/poetry to avoid the runner’s injected Requests certificate override and use the available compiler. Global coverage: 94%.

  • Extras tests: 11 passed, with 100% statement and branch coverage of poetry.utils.extras.

  • Mypy: all 380 source files passed. All applicable pre-commit hooks passed, including Ruff check and format.

  • Added tests.

  • Updated documentation — not needed for this test-only change.

CMGeorges

Prepared with Codex assistance.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/utils/test_extras.py" line_range="48" />
<code_context>
+        # Missing packages do not prevent resolving the available packages
+        (
+            [_PACKAGE_SPAM],
+            {"group0": ["foo", "spam"]},
+            ["group0"],
+            {"spam"},
</code_context>
<issue_to_address>
**Missing-package test misses later results**

When a future change stops traversal when it encounters a missing package, `stack.pop()` visits `spam` before the missing `foo`, so this assertion still passes if resolution returns immediately on a missing package; it does not verify that available packages queued after a miss are resolved.

Reverse the requested package order in this case, or add a case where an available package is popped after a missing one.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: tests/utils/test_extras.py:48


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

# Missing packages do not prevent resolving the available packages
(
[_PACKAGE_SPAM],
{"group0": ["foo", "spam"]},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Missing-package test misses later results

When a future change stops traversal when it encounters a missing package, stack.pop() visits spam before the missing foo, so this assertion still passes if resolution returns immediately on a missing package; it does not verify that available packages queued after a miss are resolved.

Reverse the requested package order in this case, or add a case where an available package is popped after a missing one.

Prompt for AI agents
In `tests/utils/test_extras.py` at line 48:

**Missing-package test misses later results**

When a future change stops traversal when it encounters a missing package, `stack.pop()` visits `spam` before the missing `foo`, so this assertion still passes if resolution returns immediately on a missing package; it does not verify that available packages queued after a miss are resolved.

Reverse the requested package order in this case, or add a case where an available package is popped after a missing one.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant