Skip to content

Commit b626549

Browse files
committed
Skip test when an obscure Windows pathlib error appears
1 parent 8332ea3 commit b626549

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

Lib/test/test_tarfile.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,9 +2736,19 @@ def setUpClass(cls):
27362736
tar.errorlevel = 0
27372737
tar.extractall(cls.control_dir, filter=cls.extraction_filter)
27382738
tar.close()
2739+
try:
2740+
paths = list(pathlib.Path(cls.control_dir).glob('**/*'))
2741+
except OSError as err:
2742+
if getattr(err, 'winerror', None) == 123:
2743+
# 123 is Windows error ERROR_INVALID_NAME
2744+
# glob() fails this way when symlink targets are too long
2745+
# Fixed in 3.8+: https://github.com/python/cpython/issues/79487
2746+
raise unittest.SkipTest('Path.glob failed')
2747+
else:
2748+
raise
27392749
cls.control_paths = set(
27402750
p.relative_to(cls.control_dir)
2741-
for p in pathlib.Path(cls.control_dir).glob('**/*'))
2751+
for p in paths)
27422752

27432753
@classmethod
27442754
def tearDownClass(cls):
@@ -3031,7 +3041,16 @@ def check_context(self, tar, filter):
30313041
self.expected_paths = set()
30323042
else:
30333043
self.raised_exception = None
3034-
self.expected_paths = set(self.outerdir.glob('**/*'))
3044+
try:
3045+
self.expected_paths = set(self.outerdir.glob('**/*'))
3046+
except OSError as err
3047+
if getattr(err, 'winerror', None) == 123:
3048+
# 123 is Windows error ERROR_INVALID_NAME
3049+
# glob() fails this way when symlink targets are too long
3050+
# Fixed in 3.8+: https://github.com/python/cpython/issues/79487
3051+
raise unittest.SkipTest('Path.glob failed')
3052+
else:
3053+
raise
30353054
self.expected_paths.discard(self.destdir)
30363055
try:
30373056
yield

0 commit comments

Comments
 (0)