summaryrefslogtreecommitdiff
path: root/Lib/test/test_glob.py
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-12-02 18:29:18 +0000
committerBrian Curtin <brian.curtin@gmail.com>2010-12-02 18:29:18 +0000
commitdf5774cfe540fba0bce7f6fdaed4179e7ffa4d8e (patch)
treec1cf4ff19954c5ea5b5661405e88402da9c77d17 /Lib/test/test_glob.py
parent10033aa0fd308d83c2c90a71951505f8e3134bea (diff)
downloadcpython-df5774cfe540fba0bce7f6fdaed4179e7ffa4d8e.tar.gz
Fix #9333. Expose os.symlink on Windows only when usable.
In order to create symlinks on Windows, SeCreateSymbolicLinkPrivilege is an account privilege that is required to be held by the user. Not only must the privilege be enabled for the account, the activated privileges for the currently running application must be adjusted to enable the requested privilege. Rather than exposing an additional function to be called prior to the user's first os.symlink call, we handle the AdjustTokenPrivileges Windows API call internally and only expose os.symlink when the privilege escalation was successful. Due to the change of only exposing os.symlink when it's available, we can go back to the original test skipping methods of checking via `hasattr`.
Diffstat (limited to 'Lib/test/test_glob.py')
-rw-r--r--Lib/test/test_glob.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py
index 1560a6bbf0..f1e1c03624 100644
--- a/Lib/test/test_glob.py
+++ b/Lib/test/test_glob.py
@@ -1,5 +1,5 @@
import unittest
-from test.support import run_unittest, TESTFN, skip_unless_symlink, can_symlink
+from test.support import run_unittest, TESTFN
import glob
import os
import shutil
@@ -25,7 +25,7 @@ class GlobTests(unittest.TestCase):
self.mktemp('ZZZ')
self.mktemp('a', 'bcd', 'EF')
self.mktemp('a', 'bcd', 'efg', 'ha')
- if can_symlink():
+ if hasattr(os, "symlink"):
os.symlink(self.norm('broken'), self.norm('sym1'))
os.symlink(self.norm('broken'), self.norm('sym2'))
@@ -98,7 +98,8 @@ class GlobTests(unittest.TestCase):
# either of these results are reasonable
self.assertIn(res[0], [self.tempdir, self.tempdir + os.sep])
- @skip_unless_symlink
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
def test_glob_broken_symlinks(self):
eq = self.assertSequencesEqual_noorder
eq(self.glob('sym*'), [self.norm('sym1'), self.norm('sym2')])