mirror of https://github.com/python/cpython
Issue #13968: Fixed newly added recursive glob test.
It was failed when run with non-empty current directory.
This commit is contained in:
parent
2c16df269a
commit
a1b16bab2f
|
@ -5,7 +5,7 @@ import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from test.support import (TESTFN, skip_unless_symlink,
|
from test.support import (TESTFN, skip_unless_symlink,
|
||||||
can_symlink, create_empty_file)
|
can_symlink, create_empty_file, change_cwd)
|
||||||
|
|
||||||
|
|
||||||
class GlobTests(unittest.TestCase):
|
class GlobTests(unittest.TestCase):
|
||||||
|
@ -266,16 +266,18 @@ class SymlinkLoopGlobTests(unittest.TestCase):
|
||||||
def test_selflink(self):
|
def test_selflink(self):
|
||||||
tempdir = TESTFN + "_dir"
|
tempdir = TESTFN + "_dir"
|
||||||
os.makedirs(tempdir)
|
os.makedirs(tempdir)
|
||||||
create_empty_file(os.path.join(tempdir, 'file'))
|
|
||||||
os.symlink(os.curdir, os.path.join(tempdir, 'link'))
|
|
||||||
self.addCleanup(shutil.rmtree, tempdir)
|
self.addCleanup(shutil.rmtree, tempdir)
|
||||||
|
with change_cwd(tempdir):
|
||||||
|
os.makedirs('dir')
|
||||||
|
create_empty_file(os.path.join('dir', 'file'))
|
||||||
|
os.symlink(os.curdir, os.path.join('dir', 'link'))
|
||||||
|
|
||||||
results = glob.glob('**', recursive=True)
|
results = glob.glob('**', recursive=True)
|
||||||
self.assertEqual(len(results), len(set(results)))
|
self.assertEqual(len(results), len(set(results)))
|
||||||
results = set(results)
|
results = set(results)
|
||||||
depth = 0
|
depth = 0
|
||||||
while results:
|
while results:
|
||||||
path = os.path.join(*([tempdir] + ['link'] * depth))
|
path = os.path.join(*(['dir'] + ['link'] * depth))
|
||||||
self.assertIn(path, results)
|
self.assertIn(path, results)
|
||||||
results.remove(path)
|
results.remove(path)
|
||||||
if not results:
|
if not results:
|
||||||
|
@ -290,7 +292,7 @@ class SymlinkLoopGlobTests(unittest.TestCase):
|
||||||
results = set(results)
|
results = set(results)
|
||||||
depth = 0
|
depth = 0
|
||||||
while results:
|
while results:
|
||||||
path = os.path.join(*([tempdir] + ['link'] * depth + ['file']))
|
path = os.path.join(*(['dir'] + ['link'] * depth + ['file']))
|
||||||
self.assertIn(path, results)
|
self.assertIn(path, results)
|
||||||
results.remove(path)
|
results.remove(path)
|
||||||
depth += 1
|
depth += 1
|
||||||
|
@ -300,7 +302,7 @@ class SymlinkLoopGlobTests(unittest.TestCase):
|
||||||
results = set(results)
|
results = set(results)
|
||||||
depth = 0
|
depth = 0
|
||||||
while results:
|
while results:
|
||||||
path = os.path.join(*([tempdir] + ['link'] * depth + ['']))
|
path = os.path.join(*(['dir'] + ['link'] * depth + ['']))
|
||||||
self.assertIn(path, results)
|
self.assertIn(path, results)
|
||||||
results.remove(path)
|
results.remove(path)
|
||||||
depth += 1
|
depth += 1
|
||||||
|
|
Loading…
Reference in New Issue