-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add more consistency tests #4983
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
Add more consistency tests #4983
Conversation
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.
Might make sense to add a check that all stdlib modules have an entry in VERSIONS
tests/check_consistent.py
Outdated
for _, dirs, files in os.walk(directory): | ||
for file in files: | ||
name, ext = os.path.splitext(file) | ||
assert name.isidentifier(), "Files must be valid modules" |
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.
Should add the name to the assertion failure to make the failure more debuggable. Same for a number of other checks below.
(Also, is there a reason not to use f-strings here?)
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.
Thanks for adding the tests! These will help prevent all sorts weird failure modes that would otherwise be possible, such as breaking the build pipeline.
Looks good, mostly left comments about missing details in error messages.
tests/check_consistent.py
Outdated
assert name.isidentifier(), "Files must be valid modules" | ||
assert ext == ".pyi", "Only stub flies allowed. Got: {} in {}".format(file, directory) | ||
for subdir in dirs: | ||
assert subdir.isidentifier(), "Directories must be valid packages" |
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.
Also include the name of the subdir in the message.
tests/check_consistent.py
Outdated
|
||
def check_stubs(): | ||
for distribution in os.listdir("stubs"): | ||
assert not os.path.isfile(distribution), "Only directories allowed in stubs" |
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.
Show distribution
in the error message.
tests/check_consistent.py
Outdated
if ext != ".pyi": | ||
assert entry in {"METADATA.toml", "README", "README.md", "README.rst"}, entry | ||
else: | ||
assert name.isidentifier(), "Bad file name in stubs" |
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.
Include name in the error message.
tests/check_consistent.py
Outdated
if os.path.isfile(os.path.join("stubs", distribution, "@python2", entry)): | ||
name, ext = os.path.splitext(entry) | ||
assert name.isidentifier(), "Bad file name in stubs" | ||
assert ext == ".pyi", "Unexpected file in @python2 stubs" |
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.
Include file name in the above two error messages.
main() | ||
check_stdlib() | ||
check_stubs() | ||
check_same_files() |
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.
Should we also validate METADATA.toml files here?
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.
I think yes. I will add a test for it too.
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.
Thanks for the updates! Can you create a follow-up issue about better dependency tests?
tests/check_consistent.py
Outdated
data = toml.loads(f.read()) | ||
assert "version" in data, f"Missing version for {distribution}" | ||
version = data["version"] | ||
msg = f"Unsupported Python version{version}" |
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.
Nit: add space after 'version'?
Follow up fo #4971