From a2cdbb8d41cd6f627eb809a326a1521ae7f78859 Mon Sep 17 00:00:00 2001 From: liormizrahi Date: Sat, 9 Nov 2024 18:56:28 +0200 Subject: [PATCH] WIP --- s3path/current_version.py | 6 +++++- tests/test_path_operations.py | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/s3path/current_version.py b/s3path/current_version.py index 2cc2e39..0f5cc3b 100644 --- a/s3path/current_version.py +++ b/s3path/current_version.py @@ -47,7 +47,7 @@ class PureS3Path(PurePath): S3 is not a file-system but we can look at it like a POSIX system. """ - _flavour = posixpath + _flavour = posixpath # not relevant after Python version 3.13 parser = posixpath __slots__ = () @@ -62,6 +62,10 @@ def __init__(self, *args): new_parts.remove(part) self._raw_paths = new_parts + if sys.version_info >= (3, 13): + self._drv, self._root, self._tail_cached = self._parse_path(self._raw_path) + else: + self._load_parts() @classmethod def from_uri(cls, uri: str): diff --git a/tests/test_path_operations.py b/tests/test_path_operations.py index 28b6d43..68e269d 100644 --- a/tests/test_path_operations.py +++ b/tests/test_path_operations.py @@ -165,7 +165,10 @@ def test_glob_nested_folders_issue_no_120(s3_mock): def test_glob_old_algo(s3_mock, enable_old_glob): - with pytest.deprecated_call(): + if sys.version_info > (3, 12): + with pytest.deprecated_call(): + test_glob(s3_mock) + else: test_glob(s3_mock) @@ -271,7 +274,11 @@ def test_rglob(s3_mock): def test_rglob_old_algo(s3_mock, enable_old_glob): - test_rglob(s3_mock) + if sys.version_info > (3, 12): + with pytest.deprecated_call(): + test_rglob(s3_mock) + else: + test_rglob(s3_mock) def test_accessor_scandir(s3_mock): @@ -299,7 +306,10 @@ def test_accessor_scandir(s3_mock): def test_accessor_scandir_old_algo(s3_mock, enable_old_glob): - with pytest.deprecated_call(): + if sys.version_info > (3, 12): + with pytest.deprecated_call(): + test_accessor_scandir(s3_mock) + else: test_accessor_scandir(s3_mock) @@ -828,6 +838,7 @@ def test_unlink(s3_mock): S3Path("/test-bucket/fake_folder").unlink(missing_ok=True) S3Path("/fake-bucket/").unlink(missing_ok=True) + def test_absolute(s3_mock): s3 = boto3.resource('s3') s3.create_bucket(Bucket='test-bucket')