summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pathlib/support
Commit message (Collapse)AuthorAgeFilesLines
* GH-128520: pathlib ABCs: improve protocol for 'openable' objects (#134101)Barney Gale2025-09-122-7/+7
| | | | | | | | | | | | | | | | | | | | | | | Rename `pathlib._os.magic_open()` to `vfsopen()`. The new name is a bit less abstract, and it aligns with the `vfspath()` method added in 5dbd27d. Per discussion on discourse[^1], adjust `vfsopen()` so that the following methods may be called: - `__open_reader__()` - `__open_writer__(mode)` - `__open_updater__(mode)` These three methods return readable, writable, and full duplex file objects respectively. In the 'writer' method, *mode* is either 'a', 'w' or 'x'. In the 'updater' method, *mode* is either 'r' or 'w'. In the pathlib ABCs, replace `ReadablePath.__open_rb__()` with `__open_reader__()`, and replace `WritablePath.__open_wb__()` with `__open_writer__()`. [^1]: https://discuss.python.org/t/open-able-objects/90238 Co-authored-by: Petr Viktorin <encukou@gmail.com>
* GH-128520: pathlib ABCs: tweak protocol for virtual path strings (#134104)Barney Gale2025-07-271-1/+1
| | | | | Adjust `pathlib._os.vfspath()` so that it doesn't try `os.fsdecode()`. I don't know that supporting `os.PathLike` arguments is a good idea, so it's best to leave it out for now.
* GH-128520: pathlib ABCs: add `JoinablePath.__vfspath__()` (#133437)Barney Gale2025-05-123-34/+32
| | | | | | | | In the abstract interface of `JoinablePath`, replace `__str__()` with `__vfspath__()`. This frees user implementations of `JoinablePath` to implement `__str__()` however they like (or not at all.) Also add `pathlib._os.vfspath()`, which calls `__fspath__()` or `__vfspath__()`.
* GH-128520: pathlib ABCs tests: use explicit text encoding (#133105)Barney Gale2025-04-282-2/+2
| | | | | Follow-up to fbffd70. Set `encoding='utf-8'` when reading and writing text in the tests for the private pathlib ABCs, which allows the tests to run with `-W error -X warn_default_encoding`
* GH-128520: pathlib ABCs: allow tests to be run externally (#131315)Barney Gale2025-03-214-19/+50
| | | | | | | | | | | | Adjust the tests for the `pathlib.types` module so that they can be run against the `pathlib-abc` PyPI package, which is a backport of the module for older Python versions. Specifically, we add a `.support.is_pypi` switch that is false in the stdlib and true in the pathlib-abc package. This controls which package we import, and whether or not we run tests against `PurePath` and `Path`. For compatibility with older Python versions, we stop using `zipfile.ZipFile.mkdir()` and `zipfile.ZipInfo._for_archive()`.
* GH-130614: pathlib ABCs: revise test suite for writable paths (#131112)Barney Gale2025-03-122-2/+69
| | | | | Test `pathlib.types._WritablePath` in a dedicated test module. These tests cover `WritableZipPath`, `WritableLocalPath` and `Path`, where the former two classes are implementations of `_WritablePath` for use in tests.
* GH-130614: pathlib ABCs: revise test suite for readable paths (#131018)Barney Gale2025-03-112-0/+423
| | | | | 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.
* GH-130614: pathlib ABCs: revise test suite for Windows path joining (#131016)Barney Gale2025-03-111-0/+6
| | | | | | 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.
* GH-130614: pathlib ABCs: revise test suite for Posix path joining (#131017)Barney Gale2025-03-101-0/+6
| | | | | | 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.
* GH-130614: pathlib ABCs: revise test suite for path joining (#130988)Barney Gale2025-03-092-0/+33
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.