From 777a39851471b630c7aa4de9d3d0c5e676517f17 Mon Sep 17 00:00:00 2001 From: Andreas Poehlmann Date: Fri, 26 Jan 2024 19:44:54 +0100 Subject: [PATCH] upath.implementations.memory: normalize to two slashes for py312 and adjust tests for netloc only memory path --- upath/implementations/memory.py | 6 ++++++ upath/tests/implementations/test_memory.py | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/upath/implementations/memory.py b/upath/implementations/memory.py index 3dfa0b3..09e564a 100644 --- a/upath/implementations/memory.py +++ b/upath/implementations/memory.py @@ -71,3 +71,9 @@ def iterdir(self): def path(self): path = super().path return "/" if path == "." else path + + def __str__(self): + s = super().__str__() + if s.startswith("memory:///"): + s = s.replace("memory:///", "memory://", 1) + return s diff --git a/upath/tests/implementations/test_memory.py b/upath/tests/implementations/test_memory.py index 6edbfad..8e84dc9 100644 --- a/upath/tests/implementations/test_memory.py +++ b/upath/tests/implementations/test_memory.py @@ -1,3 +1,5 @@ +import sys + import pytest from upath import UPath @@ -29,7 +31,10 @@ def test_is_MemoryPath(self): pytest.param( "memory://a", "memory://a", - marks=pytest.mark.xfail(reason="currently broken due to urllib parsing"), + marks=pytest.mark.xfail( + sys.version_info < (3, 12), + reason="currently broken due to urllib parsing", + ), ), ("memory://a/b", "memory://a/b"), ("memory:///", "memory://"),