bpo-33660: Fix PosixPath to resolve a relative path on root (#21974)
(cherry picked from commit 94ad6c674f7687ef22853cb8d42b440d6b42ddc8)
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 1589282..3da3571 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -2347,6 +2347,15 @@
st = os.stat(join('other_new_file'))
self.assertEqual(stat.S_IMODE(st.st_mode), 0o644)
+ def test_resolve_root(self):
+ current_directory = os.getcwd()
+ try:
+ os.chdir('/')
+ p = self.cls('spam')
+ self.assertEqual(str(p.resolve()), '/spam')
+ finally:
+ os.chdir(current_directory)
+
def test_touch_mode(self):
old_mask = os.umask(0)
self.addCleanup(os.umask, old_mask)