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

Parametrize tests for pathlib.Path.copy() #130614

Open
barneygale opened this issue Feb 26, 2025 · 3 comments
Open

Parametrize tests for pathlib.Path.copy() #130614

barneygale opened this issue Feb 26, 2025 · 3 comments
Labels
tests Tests in the Lib/test dir topic-pathlib type-feature A feature request or enhancement

Comments

@barneygale
Copy link
Contributor

barneygale commented Feb 26, 2025

We should be able to parametrize tests for pathlib's ReadablePath.copy(), e.g.:

  • Copy from Path to Path
  • Copy from Path to WritableZipPath
  • Copy from ReadableZipPath to Path
  • Copy from ReadableZipPath to WritableZipPath

Unfortunately this breaks some deep assumptions in the existing test classes, so I think we should create new suites somewhere in test.test_pathlib.

Linked PRs

@barneygale barneygale added tests Tests in the Lib/test dir topic-pathlib labels Feb 26, 2025
@srinivasreddy
Copy link
Contributor

I would like to work on it. If not taken

@Mr-Sunglasses
Copy link
Contributor

I would like to work on it. If not taken

Yes, Please go ahead :-)

@barneygale
Copy link
Contributor Author

I've already made a start on this, but I'll stop making changes and put a PR up so that others can contribute.

barneygale added a commit to barneygale/cpython that referenced this issue Feb 27, 2025
…paths

Add `test.test_pathlib.test_read`, which tests `ReadablePath` subclasses.
Tests are run against `ReadableZipPath`, `ReadableLocalPath`, and `Path`.
This test suite is mostly incomplete.

Add `test.test_pathlib.test_write`, which tests `WritablePath` subclasses.
Tests are run against `WritableZipPath`, `WritableLocalPath`, and `Path`.
This test suite is mostly complete.

Add `test.test_pathlib.support.zip_path`, which provides the `*ZipPath`
classes mentioned above. It also provides a `ZipPathGround` class that's
used by tests to make assertions about the contents of the zip file.

Add `test.test_pathlib.support.local_path`, which provides the `*LocalPath`
classes mentioned above. They're stripped-back versions of `pathlib.Path`,
basically. It also provides `LocalPathGround` class that's used by tests to
access the local filesystem.
barneygale added a commit to barneygale/cpython that referenced this issue Feb 27, 2025
…paths

Add `test.test_pathlib.test_read`, which tests `ReadablePath` subclasses.
Tests are run against `ReadableZipPath`, `ReadableLocalPath`, and `Path`.
This test suite is mostly incomplete.

Add `test.test_pathlib.test_write`, which tests `WritablePath` subclasses.
Tests are run against `WritableZipPath`, `WritableLocalPath`, and `Path`.
This test suite is mostly complete.

Add `test.test_pathlib.support.zip_path`, which provides the `*ZipPath`
classes mentioned above. It also provides a `ZipPathGround` class that's
used by tests to make assertions about the contents of the zip file.

Add `test.test_pathlib.support.local_path`, which provides the `*LocalPath`
classes mentioned above. They're stripped-back versions of `pathlib.Path`,
basically. It also provides `LocalPathGround` class that's used by tests to
access the local filesystem.
barneygale added a commit to barneygale/cpython that referenced this issue Mar 8, 2025
Test `pathlib.types._JoinablePath` in a dedicated test module. These tests
cover `LexicalPath`, `PurePath` and `Path`, where `LexicalPath` is defined
in a new `test.test_pathlib.support` package.
barneygale added a commit to barneygale/cpython that referenced this issue Mar 8, 2025
…e()`

In `pathlib.types._JoinablePath.with_name()`, retain any alternative path
separator preceding the old name, rather stripping and replacing it with a
primary separator. As a result, this method changes _only_ the name.
barneygale added a commit to barneygale/cpython that referenced this issue Mar 8, 2025
…atch()`

In `pathlib.types._JoinablePath.full_match()`, treat alternate path
separators in the path and pattern as if they were primary separators. e.g.
if the parser is `ntpath`, then `P(r'foo/bar\baz').full_match(r'*\*/*')` is
true.
barneygale added a commit that referenced this issue Mar 9, 2025
…130990)

In `pathlib.types._JoinablePath.with_name()`, retain any alternative path
separator preceding the old name, rather stripping and replacing it with a
primary separator. As a result, this method changes _only_ the name.
barneygale added a commit that referenced this issue Mar 9, 2025
#130991)

In `pathlib.types._JoinablePath.full_match()`, treat alternate path
separators in the path and pattern as if they were primary separators. e.g.
if the parser is `ntpath`, then `P(r'foo/bar\baz').full_match(r'*\*/*')` is
true.
barneygale added a commit to barneygale/cpython that referenced this issue Mar 9, 2025
barneygale added a commit that referenced this issue Mar 9, 2025
Test `pathlib.types._JoinablePath` in a dedicated test module. These tests
cover `LexicalPath`, `PurePath` and `Path`, where `LexicalPath` is defined
in a new `test.test_pathlib.support` package.
barneygale added a commit to barneygale/cpython that referenced this issue Mar 9, 2025
…ning

Test Windows-flavoured `pathlib.types._JoinablePath` in a dedicated test
module. These tests cover `LexicalWindowsPath`, `PureWindowsPath` and
`WindowsPath`, where `LexicalWindowsPath` is a simple implementation of
`_JoinablePath` for use in tests.
barneygale added a commit to barneygale/cpython that referenced this issue Mar 9, 2025
Test Posix-flavoured `pathlib.types._JoinablePath` in a dedicated test
module. These tests cover `LexicalPosixPath`, `PurePosixPath` and
`PosixPath`, where `LexicalPosixPath` is a simple implementation of
`_JoinablePath` for use in tests.
barneygale added a commit to barneygale/cpython that referenced this issue Mar 9, 2025
Test `pathlib.types._ReadablePath` in a dedicated test module. These tests
cover `ReadableZipPath`, `ReadableLocalPath` and `Path`, where the former
two classes are implementations of `_ReadablePath` for use in tests.
@picnixz picnixz added the type-feature A feature request or enhancement label Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-pathlib type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants