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

Handle other pathlib.Path.open calls in read_text, read_bytes, write_text and write_bytes #1022

Merged
merged 3 commits into from
May 26, 2024

Conversation

sassanh
Copy link
Contributor

@sassanh sassanh commented May 26, 2024

Describe the changes

The related issue or a description of the bug or feature that this PR addresses.

Tasks

  • Unit tests added that reproduce the issue or prove feature is working
  • Fix or feature added
  • Entry to release notes added
  • Pre-commit CI shows no errors
  • Unit tests passing
  • For documentation changes: The Read the Docs preview builds and looks as expected

self.skip_names,
self._path(),
mode="rb",
) as f:
return f.read()
Copy link
Member

@mrbean-bremen mrbean-bremen May 26, 2024

Choose a reason for hiding this comment

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

Ah, thanks - I was thinking about this and completely forgot it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm glad I could contribute!
Can you kindly take care of the release notes? I'm not sure about the release date.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks a lot!

Ah, there is no entry after the release yet. Just put ## Unreleased on top instead of a release description, no release date is needed - that will only be added at release time. And pytype is still failing... it can be a bit finicky.

Copy link
Member

Choose a reason for hiding this comment

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

Let me know if I shall handle the pytype errors myself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm adding __enter__ and __exit__ to some classes like FakeDirWrapper, I'm following the patterns in FakePipeWrapper.
If it needs to be handled differently, I'd be thankful if you take care of it yourself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does read have a meaning for FakeDirWrapper?

Copy link
Member

Choose a reason for hiding this comment

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

I think this is the correct way to handle this, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to add read and write methods in a meaningful way, as far as I could understand the semantics. The tests are now passing and I added the release entry, please review my changes when you got the time.

Copy link
Member

@mrbean-bremen mrbean-bremen left a comment

Choose a reason for hiding this comment

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

This looks all fine, thank you! I'll wait with the merge until you remove the [WIP].

@sassanh sassanh changed the title [WIP] Handle other pathlib.Path.open calls in read_text, read_bytes, write_text and write_bytes Handle other pathlib.Path.open calls in read_text, read_bytes, write_text and write_bytes May 26, 2024
@sassanh
Copy link
Contributor Author

sassanh commented May 26, 2024

I removed [WIP].

@mrbean-bremen mrbean-bremen merged commit 9689317 into pytest-dev:main May 26, 2024
64 checks passed
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.

None yet

2 participants