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

Pathlib /tests/conftest.py #6290

Merged
merged 9 commits into from Mar 19, 2021
Merged

Pathlib /tests/conftest.py #6290

merged 9 commits into from Mar 19, 2021

Conversation

ghost
Copy link

@ghost ghost commented Mar 16, 2021

Copy link
Member

@The-Compiler The-Compiler left a comment

Choose a reason for hiding this comment

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

I think this can be fixed in a nicer way: According to the reference docs, the pytest_ignore_collect hook has a fspath argument which you can use instead of path. That will mean fspath is a pathlib.Path object as well.

@ghost
Copy link
Author

ghost commented Mar 19, 2021

@The-Compiler pytest doesn't seem to contain the pathlib argument which is weird

def pytest_ignore_collect(path: py.path.local, config: "Config") -> Optional[bool]:

in .tox/py*/lib64/python3.*/sites-packages/_pytest/hookspeck.py

Doesnt seems like the pahlib changes made it in 6.2.X :(

@The-Compiler
Copy link
Member

Yep, you're right - they were added on December 15th and I blindly assumed there was a release since then, but the last feature release was on December 12th...

Looks like there are some issues with that change still, see pytest-dev/pytest#8361 and pytest-dev/pytest#8463.

Would you mind changing this to use the py.path API in the meantime? I don't think it makes much sense to convert from py.path to str to pathlib and back here until pytest is ready.

@RonnyPfannschmidt
Copy link

I apologise for the inconvenience, just wrap up the path into a pathlib path for now

@The-Compiler
Copy link
Member

No worries! But you're right, let's do something like fspath = pathlib.Path(path) (or perhaps pathlib.Path(str(path)), not sure) so we can already use the pathlib API and then easily migrate once the new API is available.

@RonnyPfannschmidt
Copy link

The canonical api is os.fspath, i believe pathlib calls it, so Str should not be needed

@The-Compiler
Copy link
Member

Looks great now, thanks! 👍

@The-Compiler The-Compiler merged commit 3e4be9d into qutebrowser:master Mar 19, 2021
Pull request backlog automation moved this from WIP to Done Mar 19, 2021
@ghost ghost deleted the pathlib-/tests/conftest.py branch March 19, 2021 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants