Skip to content
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

Simplify generation of test packages used in test_check #1208

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dnicolodi
Copy link
Contributor

These tests used build to invoke the setuptools.build_meta build backend on a package directory generated on the fly. The tests are only interested in the content of the package metadata and use variations of setup.cfg to generate the desired metadata.

This can be simplified to the direct generation of sdist archives with synthetic PKG-INFO metadata files. This makes the actual metadata the tests are checking obvious and avoid two test dependencies.

The tests simplification highlighted that two tests are actually testing the exact same thing. Remove one.

@dnicolodi
Copy link
Contributor Author

ping?

This will allow to reuse it in later commits. Change the function to
return a pathlib.Path instead of a string because that is what is used
internally and because it is easy to turn that into a string when
needed, but it is a bit more cumbersome to do the opposite.
These tests used `build` to invoke the `setuptools.build_meta` build
backend on a package directory generated on the fly. The tests are
only interested in the content of the package metadata and use
variations of `setup.cfg` to generate the desired metadata.

This can be simplified to the direct generation of sdist archives with
synthetic `PKG-INFO` metadata files. This makes the actual metadata
the tests are checking obvious and avoid two test dependencies.

The tests simplification highlighted that two tests are actually
testing the exact same thing. Remove one.
assert b"Metadata-Version: 1.1" in metadata
assert b"Name: test" in metadata
assert b"Version: 1.2.3" in metadata


def test_missing_pkg_info(archive_format, tmp_path):
"""Raise an exception when sdist does not contain PKG-INFO."""
filename = build_archive(
filepath = build_archive(
Copy link
Member

Choose a reason for hiding this comment

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

As an observation: we end up calling str(filepath) repeatedly, so maybe it's fine to have build_archive return a str instead of a pathlib.Path?

(No strong preference, however.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for the change is explained in the commit message. In subsequent patches I'll use the Path object instead of the string. I've a few more cleanups ready to submit but I split them in smaller PRs for easy of review.

Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

LGTM overall, thanks @dnicolodi! One small comment about a return type, which you can shoot down based on your taste.

(Thanks for doing this -- this should make test standups/runs decently faster.)

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