summaryrefslogtreecommitdiffstats
path: root/Lib/test/support
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2018-05-16 21:50:29 (GMT)
committerGitHub <noreply@github.com>2018-05-16 21:50:29 (GMT)
commite5f41d2f1e0b8b8e61d5fa427c19bd1ea90fd9a3 (patch)
tree08165b95d947b31d76f1dcf8fb261a167becd181 /Lib/test/support
parent713a9367366c88662c39ed20dd6bce22399299f1 (diff)
downloadcpython-e5f41d2f1e0b8b8e61d5fa427c19bd1ea90fd9a3.zip
cpython-e5f41d2f1e0b8b8e61d5fa427c19bd1ea90fd9a3.tar.gz
cpython-e5f41d2f1e0b8b8e61d5fa427c19bd1ea90fd9a3.tar.bz2
bpo-33522: Enable CI builds on Visual Studio Team Services (#6865)
Diffstat (limited to 'Lib/test/support')
-rw-r--r--Lib/test/support/__init__.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index f1c4c95..a6fcb1b 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -363,6 +363,20 @@ if sys.platform.startswith("win"):
_force_run(fullname, os.unlink, fullname)
_waitfor(_rmtree_inner, path, waitall=True)
_waitfor(lambda p: _force_run(p, os.rmdir, p), path)
+
+ def _longpath(path):
+ try:
+ import ctypes
+ except ImportError:
+ # No ctypes means we can't expands paths.
+ pass
+ else:
+ buffer = ctypes.create_unicode_buffer(len(path) * 2)
+ length = ctypes.windll.kernel32.GetLongPathNameW(path, buffer,
+ len(buffer))
+ if length:
+ return buffer[:length]
+ return path
else:
_unlink = os.unlink
_rmdir = os.rmdir
@@ -389,6 +403,9 @@ else:
_rmtree_inner(path)
os.rmdir(path)
+ def _longpath(path):
+ return path
+
def unlink(filename):
try:
_unlink(filename)
@@ -2381,13 +2398,15 @@ def can_xattr():
if not hasattr(os, "setxattr"):
can = False
else:
- tmp_fp, tmp_name = tempfile.mkstemp()
+ tmp_dir = tempfile.mkdtemp()
+ tmp_fp, tmp_name = tempfile.mkstemp(dir=tmp_dir)
try:
with open(TESTFN, "wb") as fp:
try:
# TESTFN & tempfile may use different file systems with
# different capabilities
os.setxattr(tmp_fp, b"user.test", b"")
+ os.setxattr(tmp_name, b"trusted.foo", b"42")
os.setxattr(fp.fileno(), b"user.test", b"")
# Kernels < 2.6.39 don't respect setxattr flags.
kernel_version = platform.release()
@@ -2398,6 +2417,7 @@ def can_xattr():
finally:
unlink(TESTFN)
unlink(tmp_name)
+ rmdir(tmp_dir)
_can_xattr = can
return can