bpo-38453: Ensure ntpath.realpath correctly resolves relative paths (GH-16967)
Ensure isabs() is always True for \\?\ prefixed paths
Avoid unnecessary usage of readlink() to avoid resolving broken links incorrectly
Ensure shutil tests run in test directory
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 636e3bd..b98e7dc 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -177,7 +177,10 @@
Returns the path of the directory.
"""
- d = tempfile.mkdtemp()
+ basedir = None
+ if sys.platform == "win32":
+ basedir = os.path.realpath(os.getcwd())
+ d = tempfile.mkdtemp(dir=basedir)
self.tempdirs.append(d)
return d
@@ -1788,8 +1791,11 @@
def setUp(self):
filename = "foo"
- self.src_dir = tempfile.mkdtemp()
- self.dst_dir = tempfile.mkdtemp()
+ basedir = None
+ if sys.platform == "win32":
+ basedir = os.path.realpath(os.getcwd())
+ self.src_dir = tempfile.mkdtemp(dir=basedir)
+ self.dst_dir = tempfile.mkdtemp(dir=basedir)
self.src_file = os.path.join(self.src_dir, filename)
self.dst_file = os.path.join(self.dst_dir, filename)
with open(self.src_file, "wb") as f: