Skip to content

Commit

Permalink
tests: update pathlib 3.12 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-- committed Oct 12, 2023
1 parent 3cebeaa commit e247c22
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions upath/tests/pathlib/test_pathlib_312.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@
except ImportError:
grp = pwd = None

from upath.core312plus import UPath
from upath.implementations.local import PosixUPath, WindowsUPath

import pytest
try:
from upath.core import UPath
from upath.implementations.local import PosixUPath, WindowsUPath
except ImportError:
UPath = PosixUPath = WindowsUPath = object
pytestmark = pytest.mark.xfail(reason="no py312 support yet")
else:
pytestmark = pytest.mark.skipif(sys.version_info[:2] != (3, 12), reason="py312 only")
pytestmark = pytest.mark.skipif(sys.version_info[:2] != (3, 12), reason="py312 only")


#
Expand Down Expand Up @@ -88,13 +84,11 @@ def test_constructor_common(self):

def test_bytes(self):
P = self.cls
message = (r"argument should be a str or an os\.PathLike object "
r"where __fspath__ returns a str, not 'bytes'")
with self.assertRaisesRegex(TypeError, message):
with self.assertRaises(TypeError):
P(b'a')
with self.assertRaisesRegex(TypeError, message):
with self.assertRaises(TypeError):
P(b'a', 'b')
with self.assertRaisesRegex(TypeError, message):
with self.assertRaises(TypeError):
P('a', b'b')
with self.assertRaises(TypeError):
P('a').joinpath(b'b')
Expand Down Expand Up @@ -556,6 +550,7 @@ def test_with_name_common(self):
self.assertRaises(ValueError, P('.').with_name, 'd.xml')
self.assertRaises(ValueError, P('/').with_name, 'd.xml')
self.assertRaises(ValueError, P('a/b').with_name, '')
self.assertRaises(ValueError, P('a/b').with_name, '.')
self.assertRaises(ValueError, P('a/b').with_name, '/c')
self.assertRaises(ValueError, P('a/b').with_name, 'c/')
self.assertRaises(ValueError, P('a/b').with_name, 'c/d')
Expand All @@ -573,6 +568,7 @@ def test_with_stem_common(self):
self.assertRaises(ValueError, P('.').with_stem, 'd')
self.assertRaises(ValueError, P('/').with_stem, 'd')
self.assertRaises(ValueError, P('a/b').with_stem, '')
self.assertRaises(ValueError, P('a/b').with_stem, '.')
self.assertRaises(ValueError, P('a/b').with_stem, '/c')
self.assertRaises(ValueError, P('a/b').with_stem, 'c/')
self.assertRaises(ValueError, P('a/b').with_stem, 'c/d')
Expand Down Expand Up @@ -636,8 +632,14 @@ def test_relative_to_common(self):
self.assertRaises(ValueError, p.relative_to, P('a/b/c'))
self.assertRaises(ValueError, p.relative_to, P('a/c'))
self.assertRaises(ValueError, p.relative_to, P('/a'))
self.assertRaises(ValueError, p.relative_to, P("../a"))
self.assertRaises(ValueError, p.relative_to, P("a/.."))
self.assertRaises(ValueError, p.relative_to, P("/a/.."))
self.assertRaises(ValueError, p.relative_to, P('/'), walk_up=True)
self.assertRaises(ValueError, p.relative_to, P('/a'), walk_up=True)
self.assertRaises(ValueError, p.relative_to, P("../a"), walk_up=True)
self.assertRaises(ValueError, p.relative_to, P("a/.."), walk_up=True)
self.assertRaises(ValueError, p.relative_to, P("/a/.."), walk_up=True)
p = P('/a/b')
self.assertEqual(p.relative_to(P('/')), P('a/b'))
self.assertEqual(p.relative_to('/'), P('a/b'))
Expand Down Expand Up @@ -666,8 +668,14 @@ def test_relative_to_common(self):
self.assertRaises(ValueError, p.relative_to, P())
self.assertRaises(ValueError, p.relative_to, '')
self.assertRaises(ValueError, p.relative_to, P('a'))
self.assertRaises(ValueError, p.relative_to, P("../a"))
self.assertRaises(ValueError, p.relative_to, P("a/.."))
self.assertRaises(ValueError, p.relative_to, P("/a/.."))
self.assertRaises(ValueError, p.relative_to, P(''), walk_up=True)
self.assertRaises(ValueError, p.relative_to, P('a'), walk_up=True)
self.assertRaises(ValueError, p.relative_to, P("../a"), walk_up=True)
self.assertRaises(ValueError, p.relative_to, P("a/.."), walk_up=True)
self.assertRaises(ValueError, p.relative_to, P("/a/.."), walk_up=True)

def test_is_relative_to_common(self):
P = self.cls
Expand Down

0 comments on commit e247c22

Please sign in to comment.