Commit Graph

7 Commits

Author SHA1 Message Date
Barney Gale 6ca0e6754e
GH-113528: Remove a couple of expensive pathlib ABC tests (#113534)
Run expensive tests for walking and globbing from `test_pathlib` but not
`test_pathlib_abc`. The ABCs are not as tightly optimised as the classes
in top-level `pathlib`, and so these tests are taking rather a long time on
some buildbots. Coverage of the main `pathlib` classes should suffice.
2023-12-28 22:44:29 +00:00
Barney Gale d1c711e757
GH-110109: Adjust `test_pathlib_abc` imports to ease backporting (#113411)
This very boring patch reduces the number of changes needed in
`test_pathlib_abc.py` when backporting to the external `pathlib_abc`
package.
2023-12-22 20:59:17 +00:00
Barney Gale a0d3d3ec9d
GH-110109: pathlib ABCs: do not vary path syntax by host OS. (#113219)
Change the value of `pathlib._abc.PurePathBase.pathmod` from `os.path` to
`posixpath`.

User subclasses of `PurePathBase` and `PathBase` previously used the host
OS's path syntax, e.g. backslashes as separators on Windows. This is wrong
in most use cases, and likely to catch developers out unless they test on
both Windows and non-Windows machines.

In this patch we change the default to POSIX syntax, regardless of OS. This
is somewhat arguable (why not make all aspects of syntax abstract and
individually configurable?) but an improvement all the same.

This change has no effect on `PurePath`, `Path`, nor their subclasses. Only
private APIs are affected.
2023-12-22 18:09:50 +00:00
Barney Gale ff5e131df5
GH-112855: Slightly improve tests for `pathlib.PurePath` pickling (#113243)
Add a few more simple test cases, like non-anchored paths. Remove misplaced
and indirect test that pickling doesn't change the `stat()` value.
2023-12-22 17:49:09 +00:00
Barney Gale 237e2cff00
GH-110109: Fix misleading `pathlib._abc.PurePathBase` repr (#113376)
`PurePathBase.__repr__()` produces a string like `MyPath('/foo')`. This
repr is incorrect/misleading when a subclass's `__init__()` method is
customized, which I expect to be the very common.

This commit moves the `__repr__()` method to `PurePath`, leaving
`PurePathBase` with the default `object` repr.

No user-facing changes because the `pathlib._abc` module remains private.
2023-12-22 15:11:16 +00:00
Barney Gale 2f0ec7fa94
GH-110109: pathlib tests: store base directory as test class attribute (#113221)
Store the test base directory as a class attribute named `base` rather than
module constants named `BASE`.

The base directory is a local file path, and therefore not ideally suited
to the pathlib ABC tests. In a future commit we'll change its value in
`test_pathlib_abc.py` such that it points to a totally fictitious path, which 
will help to ensure we're not touching the local filesystem.
2023-12-17 00:07:32 +00:00
Barney Gale d91e43ed78
GH-110109: Move tests for pathlib ABCs to new module. (#112904) 2023-12-16 19:04:33 +00:00