test: cover build config-settings and missing backend warning - #11007
test: cover build config-settings and missing backend warning#11007Shriprasad-P wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The two local version tests share quite a bit of setup and assertions; consider parametrizing them or extracting a small helper to reduce duplication and make it easier to extend behavior later.
- The tests for
_requires_isolated_buildand the no-backend warning are directly calling a private method; if feasible, prefer asserting the behavior via the public build command interface to keep tests resilient to internal refactors.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The two local version tests share quite a bit of setup and assertions; consider parametrizing them or extracting a small helper to reduce duplication and make it easier to extend behavior later.
- The tests for `_requires_isolated_build` and the no-backend warning are directly calling a private method; if feasible, prefer asserting the behavior via the public build command interface to keep tests resilient to internal refactors.
## Individual Comments
### Comment 1
<location path="tests/console/commands/test_build.py" line_range="108-116" />
<code_context>
+ tmp_tester.execute(f"--config-settings local-version={local_version_label}")
+ == 0
+ )
+ build_artifacts = tuple(
+ (tmp_project_path / "dist").glob(
+ get_package_glob(tmp_poetry, local_version=local_version_label)
+ )
+ )
+
+ assert len(build_artifacts) > 0
+ assert all(archive.exists() for archive in build_artifacts)
+ assert "`--local-version` is deprecated." not in tmp_tester.io.fetch_error()
</code_context>
<issue_to_address>
**suggestion (testing):** Strengthen `--config-settings local-version` coverage by asserting artifact names include the local version label
This test currently only verifies that some artifacts exist for the glob from `get_package_glob`, but not that the local version label is actually present in their filenames. If `get_package_glob` became too permissive, the test could still pass while ignoring the local version. Please add an assertion (e.g. `assert all(local_version_label in archive.name for archive in build_artifacts)`) to directly verify artifact naming and better protect against regressions.
Suggested implementation:
```python
assert len(build_artifacts) > 0
assert all(archive.exists() for archive in build_artifacts)
assert all(local_version_label in archive.name for archive in build_artifacts)
assert "`--local-version` is deprecated." in tmp_tester.io.fetch_error()
```
This change assumes:
1. `build_artifacts` is defined earlier in `test_build_with_config_settings_local_version` as an iterable of artifact paths.
2. `local_version_label` is the string used in the `--config-settings local-version=...` invocation.
If either name differs in your actual file, please adjust the assertion to match the existing variable names.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| build_artifacts = tuple( | ||
| (tmp_project_path / "dist").glob( | ||
| get_package_glob(tmp_poetry, local_version=local_version_label) | ||
| ) | ||
| ) | ||
|
|
||
| assert len(build_artifacts) > 0 | ||
| assert all(archive.exists() for archive in build_artifacts) | ||
| assert "`--local-version` is deprecated." not in tmp_tester.io.fetch_error() |
There was a problem hiding this comment.
suggestion (testing): Strengthen --config-settings local-version coverage by asserting artifact names include the local version label
This test currently only verifies that some artifacts exist for the glob from get_package_glob, but not that the local version label is actually present in their filenames. If get_package_glob became too permissive, the test could still pass while ignoring the local version. Please add an assertion (e.g. assert all(local_version_label in archive.name for archive in build_artifacts)) to directly verify artifact naming and better protect against regressions.
Suggested implementation:
assert len(build_artifacts) > 0
assert all(archive.exists() for archive in build_artifacts)
assert all(local_version_label in archive.name for archive in build_artifacts)
assert "`--local-version` is deprecated." in tmp_tester.io.fetch_error()This change assumes:
build_artifactsis defined earlier intest_build_with_config_settings_local_versionas an iterable of artifact paths.local_version_labelis the string used in the--config-settings local-version=...invocation.
If either name differs in your actual file, please adjust the assertion to match the existing variable names.
Pull Request Check List
Relates-to: #3155
Summary
--config-settings local-version=...path end-to-end, including artifact naming and successful exit.--local-versiondeprecation warning.No build backend definedwarning for projects without a build system/backend.Why
Issue #3155 still lists
poetry buildas an outstanding test area. The command already has strong line coverage, so this PR focuses on previously unasserted behavior rather than adding redundant execution-only tests.Testing
poetry run pytest tests/console/commands/test_build.py -q -n0poetry run ruff check tests/console/commands/test_build.pypoetry run ruff format --check tests/console/commands/test_build.pypoetry run mypy tests/console/commands/test_build.pypoetry run pre-commit run --files tests/console/commands/test_build.pyAI assistance
Cursor Agent assisted with repository inspection, identifying the coverage gaps, drafting the tests, and running validation. The contributor reviewed the complete diff and test results before publication.