Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_is_a_venv(self):
path = os.path.join(os.path.dirname(__file__), 'testdata', 'venvs', 'is_a_venv')
self.assertTrue(is_virtualenv(path))
def test_long_path_not_a_venv(self):
"""
Windows doesn't allow extremely long paths. This unit test has to be
run in Windows to be meaningful, though it shouldn't fail in other
operating systems.
"""
path = [os.path.dirname(__file__), 'testdata', 'venvs']
path.extend(['long_path_not_a_venv'] * 14)
path.append('long_path_not_a_venv_long_path_not_a_v')
path = os.path.join(*path)
self.assertFalse(is_virtualenv(path))
def test_not_a_venv(self):
path = os.path.join(os.path.dirname(__file__), 'testdata', 'venvs', 'not_a_venv')
self.assertFalse(is_virtualenv(path))
ignored = any([m.search(relpath) for m in ignore])
if os.path.isdir(fullpath):
split_fullpath = fullpath.split(os.path.sep)
# node_modules should be ignored
if 'node_modules' in split_fullpath:
continue
# __pycache__ should also be skipped
if '__pycache__' in split_fullpath:
continue
# is it probably a virtualenvironment?
if is_virtualenv(fullpath) or '.tox' in fullpath:
continue
# this is a directory
directories.append((relpath, ignored))
# is it also a package?
initpy = os.path.join(fullpath, '__init__.py')
if os.path.exists(initpy) and os.path.isfile(initpy):
packages.append((relpath, ignored))
# do the same for this directory
recurse = _find_paths(ignore, os.path.join(curpath, filename), rootpath)
files += recurse[0]
modules += recurse[1]
packages += recurse[2]
directories += recurse[3]