Skip to content

Add more consistency tests - #4983

Merged
ilevkivskyi merged 12 commits into
python:masterfrom
ilevkivskyi:add-consistency-tests
Jan 29, 2021
Merged

Add more consistency tests#4983
ilevkivskyi merged 12 commits into
python:masterfrom
ilevkivskyi:add-consistency-tests

Conversation

@ilevkivskyi

Copy link
Copy Markdown
Member

Follow up fo #4971

@hauntsaninjahauntsaninja left a comment

Copy link
Copy Markdown
Collaborator

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

Comment threadtests/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"

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.

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?)

@JukkaLJukkaL left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadtests/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"

Copy link
Copy Markdown
Contributor

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.

Comment threadtests/check_consistent.py Outdated

def check_stubs():
for distribution in os.listdir("stubs"):
assert not os.path.isfile(distribution), "Only directories allowed in stubs"

Copy link
Copy Markdown
Contributor

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.

Comment threadtests/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"

Copy link
Copy Markdown
Contributor

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.

Comment threadtests/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"

Copy link
Copy Markdown
Contributor

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()

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
MemberAuthor

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.

@JukkaLJukkaL left a comment

Copy link
Copy Markdown
Contributor

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?

Comment threadtests/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}"

Copy link
Copy Markdown
Contributor

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'?

@ilevkivskyi
ilevkivskyi merged commit e2fd852 into python:masterJan 29, 2021
@ilevkivskyi
ilevkivskyi deleted the add-consistency-tests branch January 29, 2021 17:23
Sign up for freeto 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.

4 participants

@ilevkivskyi@JelleZijlstra@JukkaL@hauntsaninja