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_os_walk(temp_dir):
scenarios = ['scenario1', 'scenario2', 'scenario3']
molecule_directory = pytest.helpers.molecule_directory()
for scenario in scenarios:
scenario_directory = os.path.join(molecule_directory, scenario)
molecule_file = pytest.helpers.get_molecule_file(scenario_directory)
os.makedirs(scenario_directory)
util.write_file(molecule_file, '')
result = [f for f in util.os_walk(molecule_directory, 'molecule.yml')]
assert 3 == len(result)
def _get_tests(self):
"""
Walk the verifier's directory for tests and returns a list.
:return: list
"""
return [filename for filename in util.os_walk(self.directory, 'test_*.py')]
def _get_tests(self):
"""
Walk the verifier's directory for tests and returns a list.
:return: list
"""
return [
filename
for filename in util.os_walk(self._config.verifier.directory, 'test_*.py')
]
def _get_files(self):
"""
Walk the project directory for tests and returns a list.
:return: list
"""
excludes = [
'.git',
'.tox',
'.vagrant',
'.venv',
os.path.basename(self._config.verifier.directory),
]
generators = [
util.os_walk(self._config.project_directory, '*.yml', excludes),
util.os_walk(self._config.project_directory, '*.yaml', excludes),
]
return [f for g in generators for f in g]
def _get_tests(self):
"""
Get a list of test files from the verifier's directory.
:return: list
"""
return list(util.os_walk(self._config.verifier.directory, 'test_*.py'))
def _get_tests(self):
"""
Walk the verifier's directory for tests and returns a list.
:return: list
"""
return [
filename
for filename in util.os_walk(self._config.verifier.directory, 'test_*.rb')
]
Prune the scenario ephemeral directory files and returns None.
"safe files" will not be pruned, including the ansible configuration
and inventory used by this scenario, the scenario state file, and
files declared as "safe_files" in the ``driver`` configuration
declared in ``molecule.yml``.
:return: None
"""
LOG.info('Pruning extra files from scenario ephemeral directory')
safe_files = [
self.config.provisioner.config_file,
self.config.provisioner.inventory_file,
self.config.state.state_file,
] + self.config.driver.safe_files
files = util.os_walk(self.ephemeral_directory, '*')
for f in files:
if not any(sf for sf in safe_files if fnmatch.fnmatch(f, sf)):
os.remove(f)
# Remove empty directories.
for dirpath, dirs, files in os.walk(self.ephemeral_directory, topdown=False):
if not dirs and not files:
os.removedirs(dirpath)