|
18 | 18 | import os
|
19 | 19 | import re
|
20 | 20 | import shutil
|
| 21 | +import stat |
21 | 22 | import subprocess
|
22 | 23 | import sys
|
23 | 24 | import sysconfig
|
@@ -194,6 +195,45 @@ def test_addsitedir(self):
|
194 | 195 | finally:
|
195 | 196 | pth_file.cleanup()
|
196 | 197 |
|
| 198 | + def test_addsitedir_dotfile(self): |
| 199 | + pth_file = PthFile('.dotfile') |
| 200 | + pth_file.cleanup(prep=True) |
| 201 | + try: |
| 202 | + pth_file.create() |
| 203 | + site.addsitedir(pth_file.base_dir, set()) |
| 204 | + self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], sys.path) |
| 205 | + self.assertIn(pth_file.base_dir, sys.path) |
| 206 | + finally: |
| 207 | + pth_file.cleanup() |
| 208 | + |
| 209 | + @unittest.skipUnless(hasattr(os, 'chflags'), 'test needs os.chflags()') |
| 210 | + def test_addsitedir_hidden_flags(self): |
| 211 | + pth_file = PthFile() |
| 212 | + pth_file.cleanup(prep=True) |
| 213 | + try: |
| 214 | + pth_file.create() |
| 215 | + st = os.stat(pth_file.file_path) |
| 216 | + os.chflags(pth_file.file_path, st.st_flags | stat.UF_HIDDEN) |
| 217 | + site.addsitedir(pth_file.base_dir, set()) |
| 218 | + self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], sys.path) |
| 219 | + self.assertIn(pth_file.base_dir, sys.path) |
| 220 | + finally: |
| 221 | + pth_file.cleanup() |
| 222 | + |
| 223 | + @unittest.skipUnless(sys.platform == 'win32', 'test needs Windows') |
| 224 | + @support.requires_subprocess() |
| 225 | + def test_addsitedir_hidden_file_attribute(self): |
| 226 | + pth_file = PthFile() |
| 227 | + pth_file.cleanup(prep=True) |
| 228 | + try: |
| 229 | + pth_file.create() |
| 230 | + subprocess.check_call(['attrib', '+H', pth_file.file_path]) |
| 231 | + site.addsitedir(pth_file.base_dir, set()) |
| 232 | + self.assertNotIn(site.makepath(pth_file.good_dir_path)[0], sys.path) |
| 233 | + self.assertIn(pth_file.base_dir, sys.path) |
| 234 | + finally: |
| 235 | + pth_file.cleanup() |
| 236 | + |
197 | 237 | # This tests _getuserbase, hence the double underline
|
198 | 238 | # to distinguish from a test for getuserbase
|
199 | 239 | def test__getuserbase(self):
|
|
0 commit comments