Skip to content

test: verify build format artifacts - #11097

Open
kokokoXUY wants to merge 1 commit into
python-poetry:mainfrom
kokokoXUY:test/build-format-artifacts
Open

kokokoXUY wants to merge 1 commit into
python-poetry:mainfrom
kokokoXUY:test/build-format-artifacts

Conversation

@kokokoXUY

@kokokoXUY kokokoXUY commented Sep 25, 2026 •

Copy link
Copy Markdown

Relates-to: #3155

The existing poetry build --format test checks only that at least one artifact exists for sdist, wheel, and all. It would still pass if a single-format build produced an unwanted extra artifact. This test-only change checks the exact artifact suffixes and counts for each format.

Validation on Windows with Python 3.12.7:

  • pytest tests/console/commands/test_build.py -q -o addopts=: 32 passed.
  • mypy tests/console/commands/test_build.py: passed.
  • pre-commit run --files tests/console/commands/test_build.py: passed.
  • git diff --check: passed.

Pull Request Check List

  • Added tests for changed code (strengthened the existing parameterized test).
  • Updated documentation for changed code (not applicable: no user-facing behavior changed).

Disclosure: this change was prepared with an AI coding assistant (DeepSeek) under my direction; I reviewed the diff and the commands above before pushing.

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Sep 25, 2026

@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 reviewed your changes and they look great!

Sourcery assessment

Approved.


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

Comment thread tests/console/commands/test_build.py Outdated
)
assert len(build_artifacts) > 0
assert all(archive.exists() for archive in build_artifacts)
assert {archive.suffix for archive in build_artifacts} == expected_suffixes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should use splitext from poetry-core to check the complete suffix.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — thanks for the pointer. I switched the assertion to the complete suffix via splitext from poetry.core.packages.utils.utils:

-    assert {archive.suffix for archive in build_artifacts} == expected_suffixes
+    assert {splitext(archive)[1] for archive in build_artifacts} == expected_suffixes

and the expectations now name the full suffixes (.tar.gz for sdist, .whl for wheel, both for all). That closes the gap Path.suffix left open: a sdist named foo-1.0.tar.gz was only being checked as .gz.

Rebased on main (3ea141d) and re-ran:

  • pytest tests/console/commands/test_build.py -q -n0 -p no:randomly → 32 passed
  • mypy tests/console/commands/test_build.py → clean
  • pre-commit run --files tests/console/commands/test_build.py → passed

Disclosure: this change was prepared with an AI coding assistant (DeepSeek) under my direction; I reviewed the diff and the commands above before pushing.

Use splitext() from poetry-core to assert the complete suffix so that a
sdist is checked as .tar.gz instead of just .gz.

@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.

Sourcery assessment

Approved.

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.

2 participants