コード例 #1
0
    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'))
コード例 #2
0
    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_*.yml")]
コード例 #3
0
    def prune(self):
        """
        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)
コード例 #4
0
ファイル: yamllint.py プロジェクト: corserp/corserp
    def _get_files(self):
        """
        Walk the project directory for tests and returns a list.

        :return: list
        """
        excludes = [
            '.tox',
            '.git',
            '.vagrant',
            '.molecule',
        ]
        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]
コード例 #5
0
ファイル: testinfra.py プロジェクト: kireledan/molecule
    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')
        ]
コード例 #6
0
ファイル: yamllint.py プロジェクト: kireledan/molecule
    def _get_files(self):
        """
        Walk the project directory for tests and returns a list.

        :return: list
        """
        excludes = [
            '.tox',
            '.git',
            '.vagrant',
            '.molecule',
        ]
        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]
コード例 #7
0
    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]
コード例 #8
0
    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')
        ]
コード例 #9
0
    def _get_tests(self):
        """
        Walk the verifier's directory for tests and returns a list.

        :return: list
        """
        return sorted([
            filename for filename in util.os_walk(
                self.directory, "test_*.py", followlinks=True)
        ])
コード例 #10
0
ファイル: test_util.py プロジェクト: tabulon-ext/molecule
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)
コード例 #11
0
ファイル: test_util.py プロジェクト: kireledan/molecule
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)
コード例 #12
0
ファイル: test_util.py プロジェクト: retr0h/molecule
def test_os_walk(temp_dir):
    scenarios = ['scenario1', 'scenario2', 'scenario3']
    molecule_directory = config.molecule_directory(temp_dir.strpath)
    for scenario in scenarios:
        scenario_directory = os.path.join(molecule_directory, scenario)
        molecule_file = config.molecule_file(scenario_directory)
        os.makedirs(scenario_directory)
        open(molecule_file, 'a').close()

    result = [f for f in util.os_walk(molecule_directory, 'molecule.yml')]
    assert 3 == len(result)
コード例 #13
0
ファイル: base.py プロジェクト: sysgazer/molecule
    def prune(self):
        """
        Prune the ephemeral directory with the exception of safe files and
        returns None.

        :return: None
        """
        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._config.scenario.ephemeral_directory, '*')
        for f in files:
            if all(sf not in f for sf in safe_files):
                os.remove(f)
コード例 #14
0
    def prune(self):
        """
        Prune the ephemeral directory with the exception of safe files and
        returns None.

        :return: None
        """
        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._config.scenario.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._config.scenario.ephemeral_directory, topdown=False):
            if not dirs and not files:
                os.removedirs(dirpath)
コード例 #15
0
ファイル: base.py プロジェクト: kireledan/molecule
    def prune(self):
        """
        Prune the ephemeral directory with the exception of safe files and
        returns None.

        :return: None
        """
        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._config.scenario.ephemeral_directory, '*')
        for f in files:
            if all(sf not in f for sf in safe_files):
                os.remove(f)

        # Remove empty directories.
        for dirpath, dirs, files in os.walk(
                self._config.scenario.ephemeral_directory):
            if not dirs and not files:
                os.rmdir(dirpath)