Skip to content

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

Merged
bluetech merged 1 commit intopytest-dev:mainfrom
bluetech:unnecessary-py-path
Mar 14, 2021
Merged

Remove/replace some unneeded usages of py.path#8440
bluetech merged 1 commit intopytest-dev:mainfrom
bluetech:unnecessary-py-path

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.


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.

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