Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
self.assertTrue(
all(
[
glob.globmatch(
x, './**/./../*.py', flags=self.flags
) for x in glob.glob('./**/./../*.py', flags=self.flags)
]
)
)
self.assertTrue(
all(
[
glob.globmatch(
x, './///**///./../*.py', flags=self.flags
) for x in glob.glob('./**/.//////..////*.py', flags=self.flags)
]
)
)
self.assertTrue(
all(
[
glob.globmatch(
x, '**/docs/**', flags=self.flags
) for x in glob.glob('**/docs/**', flags=self.flags)
]
)
)
self.assertTrue(
all(
[
glob.globmatch(
def test_cwd(self):
"""Test root level glob on current working directory."""
with change_cwd(self.tempdir):
self.assert_equal(glob.glob('EF'), ['EF'])
self.assertTrue(
all(
[
glob.globmatch(
x, '**/docs/**|!**/*.md', flags=self.flags | glob.SPLIT
) for x in glob.glob('**/docs/**|!**/*.md', flags=self.flags | glob.SPLIT)
]
)
)
self.assertTrue(
all(
[
glob.globmatch(
x, '!**/*.md', flags=self.flags | glob.SPLIT
) for x in glob.glob('!**/*.md', flags=self.flags | glob.SPLIT)
]
)
)
self.assertFalse(
all(
[
glob.globmatch(
x, '**/docs/**|!**/*.md', flags=self.flags | glob.SPLIT
) for x in glob.glob('**/docs/**', flags=self.flags | glob.SPLIT)
]
def test_drive_insensitive(self):
"""Test drive case insensitivity."""
cwd = os.getcwd()
filepath = os.path.join(cwd, 'README.md')
self.assertEqual([filepath], glob.glob(filepath.replace('\\', '\\\\')))
self.assertEqual(
[self.RE_DRIVE.sub(lambda m: m.group(0).upper(), filepath)],
glob.glob(filepath.replace('\\', '\\\\').upper())
)
self.assertEqual(
[self.RE_DRIVE.sub(lambda m: m.group(0).lower(), filepath)],
glob.glob(filepath.replace('\\', '\\\\').lower())
)
def test_tilde(self):
"""Test tilde."""
files = os.listdir(os.path.expanduser('~'))
self.assertEqual(len(glob.glob('~/*', flags=glob.T | glob.D)), len(files))
self.assertTrue(
all(
[
glob.globmatch(
x, '**/docs/**|!**/*.md', flags=self.flags | glob.SPLIT | glob.MARK
) for x in glob.glob('**/docs/**|!**/*.md', flags=self.flags | glob.SPLIT | glob.MARK)
]
)
)
self.assertTrue(
all(
[
glob.globmatch(
x, '!**/*.md', flags=self.flags | glob.SPLIT | glob.MARK
) for x in glob.glob('!**/*.md', flags=self.flags | glob.SPLIT | glob.MARK)
]
)
)
self.assertFalse(
all(
[
glob.globmatch(
x, '**/docs/**|!**/*.md', flags=self.flags | glob.SPLIT | glob.MARK
) for x in glob.glob('**/docs/**', flags=self.flags | glob.SPLIT | glob.MARK)
]
def test_tilde_globmatch_no_tilde(self):
"""Test tilde in `globmatch` environment but with tilde disabled."""
files = os.listdir(os.path.expanduser('~'))
gfiles = glob.globfilter(
glob.glob('~/*', flags=glob.T | glob.D),
'~/*', flags=glob.D | glob.P
)
self.assertNotEqual(len(files), len(gfiles))
# UNC mounts are special cases and it matters there.
self.assertTrue(
all(
[
glob.globmatch(
x, '**/../*.{md,py}', flags=self.flags
) for x in glob.glob('**/../*.{md,py}', flags=self.flags)
]
)
)
self.assertTrue(
all(
[
glob.globmatch(
x, './**/./../*.py', flags=self.flags
) for x in glob.glob('./**/./../*.py', flags=self.flags)
]
)
)
self.assertTrue(
all(
[
glob.globmatch(
x, './///**///./../*.py', flags=self.flags
) for x in glob.glob('./**/.//////..////*.py', flags=self.flags)
]
)
)
self.assertTrue(
all(
[
glob.globmatch(
def test_drive_insensitive(self):
"""Test drive case insensitivity."""
cwd = os.getcwd()
filepath = os.path.join(cwd, 'README.md')
self.assertEqual([filepath], glob.glob(filepath.replace('\\', '\\\\')))
self.assertEqual(
[self.RE_DRIVE.sub(lambda m: m.group(0).upper(), filepath)],
glob.glob(filepath.replace('\\', '\\\\').upper())
)
self.assertEqual(
[self.RE_DRIVE.sub(lambda m: m.group(0).lower(), filepath)],
glob.glob(filepath.replace('\\', '\\\\').lower())
)
def test_start(self):
"""Test that starting directory/files are handled properly."""
self.assertEqual(
sorted(['docs', 'wcmatch', 'readme.md']),
sorted([each.lower() for each in glob.glob(['BAD', 'docs', 'WCMATCH', 'readme.MD'], flags=glob.I)])
)