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

Remove/replace some unneeded usages of py.path #8440

Merged
merged 1 commit into from
Mar 14, 2021

Conversation

bluetech
Copy link
Member

As discussed in #8251 (comment) I am trying to find remaining py.path usages by completely removing it and seeing what breaks. These are the simple cases I found, mostly in the docs and tests. No user-facing changes.

@@ -5,9 +5,9 @@
pytest_plugins = ("pytester",)


def test_failure_demo_fails_properly(testdir):
target = testdir.tmpdir.join(os.path.basename(failure_demo))
def test_failure_demo_fails_properly(pytester):
Copy link
Member

Choose a reason for hiding this comment

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

as a followup we might want to make this use examples

Copy link
Member Author

Choose a reason for hiding this comment

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

This one I'm not exactly sure where it's used, so left it as is.

@@ -30,8 +30,8 @@ def __init__(self, version, picklefile):
self.picklefile = picklefile

def dumps(self, obj):
dumpfile = self.picklefile.dirpath("dump.py")
dumpfile.write(
dumpfile = self.picklefile.parent / "dump.py"
Copy link
Member

Choose a reason for hiding this comment

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

lets use Path.with_name for those cases instead of path.parent / "newname"

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, changed.

tmpdir.chdir() # change to pytest-provided temporary directory
tmpdir.join("samplefile.ini").write("# testdata")
def initdir(self, tmp_path):
os.chdir(tmp_path) # change to pytest-provided temporary directory
Copy link
Member

Choose a reason for hiding this comment

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

followup consideration: do we want to put monkeypatch.chdir in here for giving a better example

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, I changed to that.

@bluetech bluetech force-pushed the unnecessary-py-path branch from e34d3f9 to 59251e8 Compare March 14, 2021 12:51
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

Lovely

@RonnyPfannschmidt
Copy link
Member

failures is unrelated doc linkage issue

cc @evildmp as that's probably going to be part of great loop

@bluetech bluetech merged commit 63bc49d into pytest-dev:main Mar 14, 2021
@bluetech bluetech deleted the unnecessary-py-path branch March 15, 2021 08:09
Sign up for free to 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.

3 participants