From c02f43a5f4c0e145d55b36b4e4abf148fe34b13f Mon Sep 17 00:00:00 2001 From: Alexey Izbyshev Date: Thu, 22 Feb 2018 12:50:20 +0300 Subject: [PATCH 1/2] bpo-32907: pathlib: Fix test_resolve_common failure on Windows Canonicalize the temporary directory path since it is used in comparisons with other canonicalized paths. Use Path.resolve() instead of os.path.realpath() to ensure that symlinks and "short" (8.3) filenames are resolved on Windows. --- Lib/test/test_pathlib.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index e56e0d20844ec5..4d3e34b3d0ee41 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1520,6 +1520,11 @@ def test_resolve_common(self): self._check_resolve_relative(p, P(BASE, 'foo', 'in', 'spam'), False) # Now create absolute symlinks d = tempfile.mkdtemp(suffix='-dirD') + # bpo-32907: Canonicalize the temporary directory path since + # it is used in comparisons with other canonicalized paths below. + # Use Path.resolve() instead of os.path.realpath() to ensure that + # symlinks and "short" (8.3) filenames are resolved on Windows. + d = str(P(d).resolve()) self.addCleanup(support.rmtree, d) os.symlink(os.path.join(d), join('dirA', 'linkX')) os.symlink(join('dirB'), os.path.join(d, 'linkY')) From c72f2c03bef02003034e0874323b39d9219f2c41 Mon Sep 17 00:00:00 2001 From: Alexey Izbyshev Date: Fri, 23 Feb 2018 02:02:59 +0300 Subject: [PATCH 2/2] Add NEWS entry --- Misc/NEWS.d/next/Tests/2018-02-23-02-01-40.bpo-32907.kno5Ua.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Tests/2018-02-23-02-01-40.bpo-32907.kno5Ua.rst diff --git a/Misc/NEWS.d/next/Tests/2018-02-23-02-01-40.bpo-32907.kno5Ua.rst b/Misc/NEWS.d/next/Tests/2018-02-23-02-01-40.bpo-32907.kno5Ua.rst new file mode 100644 index 00000000000000..65d64b7b463bdb --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2018-02-23-02-01-40.bpo-32907.kno5Ua.rst @@ -0,0 +1,2 @@ +Fix test_pathlib to not fail if tempfile.mkdtemp() returns a non-canonical +path.