-
Notifications
You must be signed in to change notification settings - Fork 306
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
base: main
Are you sure you want to change the base?
Conversation
1d76b1c
to
05207ec
Compare
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( |
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.
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.)
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.
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.
05207ec
to
2ca55db
Compare
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.
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.)
These tests used
build
to invoke thesetuptools.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 ofsetup.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.