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

Use pytest Node.from_parent if available #9263

Merged
merged 5 commits into from Aug 4, 2020

Conversation

@llchan
Copy link
Contributor

@llchan llchan commented Aug 4, 2020

The pytest Node construction API has changed to prefer a Node.from_parent factory over the raw constructor [1]. This PR updates a few points to conform to the recommended API to avoid the PytestDeprecationWarning that arises when tests are being collected with pytest 6+.

[1] https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent

Copy link
Member

@gvanrossum gvanrossum left a comment

Thanks, I think I had seen these deprecation warnings a few times.

A thought: perhaps we could simplify things and just require pytest >= 5.4 in the test reps?

@llchan llchan force-pushed the llchan:pytest-Node.from_parent branch from 3eb8071 to 5ac89ea Aug 4, 2020
@llchan
Copy link
Contributor Author

@llchan llchan commented Aug 4, 2020

I have no objection to that, if everyone's on board with requiring a recent pytest for static analysis tests. Would certainly keep this cleaner.

Also I force-pushed with a minor fix to shift a variable annotation to a type comment, since it looks like 3.5 is still part of the CI suite.

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Aug 4, 2020

Okay, can you make it so? Hopefully pytest 5.4 still supports 3.5...

@llchan
Copy link
Contributor Author

@llchan llchan commented Aug 4, 2020

Done. Pushed it up as a separate commit, but we can squash before merging to keep the diff cleaner (I unwound some other misc changes to cancel out when we squash).

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Aug 4, 2020

Thanks. Please don't squash anything, we do that on merging. Squashing earlier confuses the code review.

@llchan
Copy link
Contributor Author

@llchan llchan commented Aug 4, 2020

Since we're already bumping test requirements from pytest 5.3.x to 5.4+, I figured I would try bumping up to the latest pytest 6.x.x (which is where I ran into the PytestDeprecationWarning becoming an error in the first place). Most notably, this release adds types to the pytest package, which allows us to remove some type ignores in the mypy test code. Waiting to see what CI looks like but if that's green and there are no objections, I think we can just bump this up for the additional type safety.

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Aug 4, 2020

Awesome! I am anxiously awaiting the test results. :)

@gvanrossum gvanrossum merged commit 3e77959 into python:master Aug 4, 2020
3 checks passed
3 checks passed
build (windows-py37-32)
Details
build (windows-py37-64)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants