From 790721d93ad6ff7304c23bfc94779f5c660a844d Mon Sep 17 00:00:00 2001 From: barneygale Date: Mon, 17 May 2021 01:07:19 +0100 Subject: [PATCH] bpo-38671: Add test that `pathlib.Path.resolve()` returns an absolute path. Authored by Tzu-ping Chung (uranusjr) --- Lib/test/test_pathlib.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 6ed08f7e70ce3d..4fbd46f4923c88 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1799,6 +1799,16 @@ def test_resolve_dot(self): # Non-strict self.assertEqual(r.resolve(strict=False), p / '3' / '4') + def test_resolve_nonexist_relative_issue38671(self): + p = self.cls('non', 'exist') + + old_cwd = os.getcwd() + os.chdir(BASE) + try: + self.assertEqual(p.resolve(), self.cls(BASE, p)) + finally: + os.chdir(old_cwd) + def test_with(self): p = self.cls(BASE) it = p.iterdir()