diff options
author | Brian Curtin <brian.curtin@gmail.com> | 2010-12-02 18:29:18 (GMT) |
---|---|---|
committer | Brian Curtin <brian.curtin@gmail.com> | 2010-12-02 18:29:18 (GMT) |
commit | 52173d4959a1c1e961efab2522e4ba8a22a3c7c6 (patch) | |
tree | a89463de7c0db84aa60ef25bc05caf8837e2cc33 /Lib/test/test_glob.py | |
parent | 02524629f39bb70f4ea00ab8e64d694e08719227 (diff) | |
download | cpython-52173d4959a1c1e961efab2522e4ba8a22a3c7c6.zip cpython-52173d4959a1c1e961efab2522e4ba8a22a3c7c6.tar.gz cpython-52173d4959a1c1e961efab2522e4ba8a22a3c7c6.tar.bz2 |
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.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py index 1560a6b..f1e1c03 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')]) |