diff --git a/molecule/command/base.py b/molecule/command/base.py index 717dc9656f..0ae67a9aaa 100644 --- a/molecule/command/base.py +++ b/molecule/command/base.py @@ -89,8 +89,8 @@ def execute_cmdline_scenarios(scenario_name, args, command_args): :returns: None """ - scenarios = molecule.scenarios.Scenarios( - get_configs(args, command_args), scenario_name) + scenarios = molecule.scenarios.Scenarios(get_configs(args, command_args), + scenario_name) scenarios.print_matrix() for scenario in scenarios: try: diff --git a/molecule/command/check.py b/molecule/command/check.py index 00288f8f60..3055a9b58b 100644 --- a/molecule/command/check.py +++ b/molecule/command/check.py @@ -73,12 +73,11 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) def check(ctx, scenario_name): # pragma: no cover """ Use the provisioner to perform a Dry-Run (destroy, dependency, create, diff --git a/molecule/command/cleanup.py b/molecule/command/cleanup.py index dfd312d6c8..6004de8911 100644 --- a/molecule/command/cleanup.py +++ b/molecule/command/cleanup.py @@ -82,12 +82,11 @@ def execute(self): @click.command(name='cleanup') @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) def cleanup(ctx, scenario_name): # pragma: no cover """ Use the provisioner to cleanup any changes made to external systems during diff --git a/molecule/command/converge.py b/molecule/command/converge.py index 9978b752b2..5f89cf0cd7 100644 --- a/molecule/command/converge.py +++ b/molecule/command/converge.py @@ -83,12 +83,11 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) @click.argument('ansible_args', nargs=-1, type=click.UNPROCESSED) def converge(ctx, scenario_name, ansible_args): # pragma: no cover """ diff --git a/molecule/command/create.py b/molecule/command/create.py index 73db28203d..7b21cd509b 100644 --- a/molecule/command/create.py +++ b/molecule/command/create.py @@ -94,17 +94,15 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) -@click.option( - '--driver-name', - '-d', - type=click.Choice(config.molecule_drivers()), - help='Name of driver to use. (docker)') +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--driver-name', + '-d', + type=click.Choice(config.molecule_drivers()), + help='Name of driver to use. (docker)') def create(ctx, scenario_name, driver_name): # pragma: no cover """ Use the provisioner to start the instances. """ args = ctx.obj.get('args') diff --git a/molecule/command/dependency.py b/molecule/command/dependency.py index e8f76529d4..a6ff7aef50 100644 --- a/molecule/command/dependency.py +++ b/molecule/command/dependency.py @@ -73,12 +73,11 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) def dependency(ctx, scenario_name): # pragma: no cover """ Manage the role's dependencies. """ args = ctx.obj.get('args') diff --git a/molecule/command/destroy.py b/molecule/command/destroy.py index 7492848c7c..415af4f5a2 100644 --- a/molecule/command/destroy.py +++ b/molecule/command/destroy.py @@ -98,22 +98,19 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) -@click.option( - '--driver-name', - '-d', - type=click.Choice(config.molecule_drivers()), - help='Name of driver to use. (docker)') -@click.option( - '--all/--no-all', - '__all', - default=False, - help='Destroy all scenarios. Default is False.') +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--driver-name', + '-d', + type=click.Choice(config.molecule_drivers()), + help='Name of driver to use. (docker)') +@click.option('--all/--no-all', + '__all', + default=False, + help='Destroy all scenarios. Default is False.') def destroy(ctx, scenario_name, driver_name, __all): # pragma: no cover """ Use the provisioner to destroy the instances. """ args = ctx.obj.get('args') diff --git a/molecule/command/idempotence.py b/molecule/command/idempotence.py index 274d60924b..e07b2363e9 100644 --- a/molecule/command/idempotence.py +++ b/molecule/command/idempotence.py @@ -139,12 +139,11 @@ def _non_idempotent_tasks(self, output): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) def idempotence(ctx, scenario_name): # pragma: no cover """ Use the provisioner to configure the instances and parse the output to diff --git a/molecule/command/init/base.py b/molecule/command/init/base.py index 8d1e4fa18b..daaa5aef5f 100644 --- a/molecule/command/init/base.py +++ b/molecule/command/init/base.py @@ -63,8 +63,8 @@ def _process_templates(self, def _resolve_template_dir(self, template_dir): if not os.path.isabs(template_dir): - template_dir = os.path.join( - os.path.dirname(__file__), os.path.pardir, os.path.pardir, - 'cookiecutter', template_dir) + template_dir = os.path.join(os.path.dirname(__file__), + os.path.pardir, os.path.pardir, + 'cookiecutter', template_dir) return template_dir diff --git a/molecule/command/init/role.py b/molecule/command/init/role.py index 73f5e8bbec..5e3b06f165 100644 --- a/molecule/command/init/role.py +++ b/molecule/command/init/role.py @@ -79,34 +79,31 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--dependency-name', - type=click.Choice(['galaxy']), - default='galaxy', - help='Name of dependency to initialize. (galaxy)') -@click.option( - '--driver-name', - '-d', - type=click.Choice(config.molecule_drivers()), - default='docker', - help='Name of driver to initialize. (docker)') -@click.option( - '--lint-name', - type=click.Choice(['yamllint']), - default='yamllint', - help='Name of lint to initialize. (yamllint)') -@click.option( - '--provisioner-name', - type=click.Choice(['ansible']), - default='ansible', - help='Name of provisioner to initialize. (ansible)') -@click.option( - '--role-name', '-r', required=True, help='Name of the role to create.') -@click.option( - '--verifier-name', - type=click.Choice(config.molecule_verifiers()), - default='testinfra', - help='Name of verifier to initialize. (testinfra)') +@click.option('--dependency-name', + type=click.Choice(['galaxy']), + default='galaxy', + help='Name of dependency to initialize. (galaxy)') +@click.option('--driver-name', + '-d', + type=click.Choice(config.molecule_drivers()), + default='docker', + help='Name of driver to initialize. (docker)') +@click.option('--lint-name', + type=click.Choice(['yamllint']), + default='yamllint', + help='Name of lint to initialize. (yamllint)') +@click.option('--provisioner-name', + type=click.Choice(['ansible']), + default='ansible', + help='Name of provisioner to initialize. (ansible)') +@click.option('--role-name', + '-r', + required=True, + help='Name of the role to create.') +@click.option('--verifier-name', + type=click.Choice(config.molecule_verifiers()), + default='testinfra', + help='Name of verifier to initialize. (testinfra)') def role(ctx, dependency_name, driver_name, lint_name, provisioner_name, role_name, verifier_name): # pragma: no cover """ Initialize a new role for use with Molecule. """ diff --git a/molecule/command/init/scenario.py b/molecule/command/init/scenario.py index 2086b5cc66..3e5aae73eb 100644 --- a/molecule/command/init/scenario.py +++ b/molecule/command/init/scenario.py @@ -118,46 +118,39 @@ def _default_scenario_exists(ctx, param, value): # pragma: no cover @click.command() @click.pass_context -@click.option( - '--dependency-name', - type=click.Choice(['galaxy']), - default='galaxy', - help='Name of dependency to initialize. (galaxy)') -@click.option( - '--driver-name', - '-d', - type=click.Choice(config.molecule_drivers()), - default='docker', - help='Name of driver to initialize. (docker)') -@click.option( - '--lint-name', - type=click.Choice(['yamllint']), - default='yamllint', - help='Name of lint to initialize. (ansible-lint)') -@click.option( - '--provisioner-name', - type=click.Choice(['ansible']), - default='ansible', - help='Name of provisioner to initialize. (ansible)') -@click.option( - '--role-name', - '-r', - required=False, - callback=_role_exists, - help='Name of the role to create.') -@click.option( - '--scenario-name', - '-s', - default=command_base.MOLECULE_DEFAULT_SCENARIO_NAME, - required=True, - callback=_default_scenario_exists, - help='Name of the scenario to create. ({})'.format( - command_base.MOLECULE_DEFAULT_SCENARIO_NAME)) -@click.option( - '--verifier-name', - type=click.Choice(config.molecule_verifiers()), - default='testinfra', - help='Name of verifier to initialize. (testinfra)') +@click.option('--dependency-name', + type=click.Choice(['galaxy']), + default='galaxy', + help='Name of dependency to initialize. (galaxy)') +@click.option('--driver-name', + '-d', + type=click.Choice(config.molecule_drivers()), + default='docker', + help='Name of driver to initialize. (docker)') +@click.option('--lint-name', + type=click.Choice(['yamllint']), + default='yamllint', + help='Name of lint to initialize. (ansible-lint)') +@click.option('--provisioner-name', + type=click.Choice(['ansible']), + default='ansible', + help='Name of provisioner to initialize. (ansible)') +@click.option('--role-name', + '-r', + required=False, + callback=_role_exists, + help='Name of the role to create.') +@click.option('--scenario-name', + '-s', + default=command_base.MOLECULE_DEFAULT_SCENARIO_NAME, + required=True, + callback=_default_scenario_exists, + help='Name of the scenario to create. ({})'.format( + command_base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--verifier-name', + type=click.Choice(config.molecule_verifiers()), + default='testinfra', + help='Name of verifier to initialize. (testinfra)') def scenario(ctx, dependency_name, driver_name, lint_name, provisioner_name, role_name, scenario_name, verifier_name): # pragma: no cover """ Initialize a new scenario for use with Molecule. """ diff --git a/molecule/command/init/template.py b/molecule/command/init/template.py index a9bb77a761..1bd7c9a20a 100644 --- a/molecule/command/init/template.py +++ b/molecule/command/init/template.py @@ -76,20 +76,18 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--url', - required=True, - help='URL to the Cookiecutter templates repository.') +@click.option('--url', + required=True, + help='URL to the Cookiecutter templates repository.') @click.option( '--no-input/--input', default=False, help=('Do not prompt for parameters and only use cookiecutter.json for ' 'content. (false)')) -@click.option( - '--role-name', - '-r', - default='role_name', - help='Name of the role to create.') +@click.option('--role-name', + '-r', + default='role_name', + help='Name of the role to create.') def template(ctx, url, no_input, role_name): # pragma: no cover """ Initialize a new role from a Cookiecutter URL. """ command_args = { diff --git a/molecule/command/lint.py b/molecule/command/lint.py index 0fc919d22c..0f809315ac 100644 --- a/molecule/command/lint.py +++ b/molecule/command/lint.py @@ -82,12 +82,11 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) def lint(ctx, scenario_name): # pragma: no cover """ Lint the role. """ args = ctx.obj.get('args') diff --git a/molecule/command/list.py b/molecule/command/list.py index 4a926e1c50..da9bc4d906 100644 --- a/molecule/command/list.py +++ b/molecule/command/list.py @@ -91,12 +91,11 @@ def execute(self): @click.command() @click.pass_context @click.option('--scenario-name', '-s', help='Name of the scenario to target.') -@click.option( - '--format', - '-f', - type=click.Choice(['simple', 'plain', 'yaml']), - default='simple', - help='Change output format. (simple)') +@click.option('--format', + '-f', + type=click.Choice(['simple', 'plain', 'yaml']), + default='simple', + help='Change output format. (simple)') def list(ctx, scenario_name, format): # pragma: no cover """ Lists status of instances. """ args = ctx.obj.get('args') @@ -107,8 +106,8 @@ def list(ctx, scenario_name, format): # pragma: no cover } statuses = [] - s = scenarios.Scenarios( - base.get_configs(args, command_args), scenario_name) + s = scenarios.Scenarios(base.get_configs(args, command_args), + scenario_name) for scenario in s: statuses.extend(base.execute_subcommand(scenario.config, subcommand)) diff --git a/molecule/command/login.py b/molecule/command/login.py index 7a007af7e1..829f9ce5e1 100644 --- a/molecule/command/login.py +++ b/molecule/command/login.py @@ -110,8 +110,8 @@ def _get_hostname(self, hosts): else: msg = ('There are {} running hosts. Please specify ' 'which with --host.\n\n' - 'Available hosts:\n{}'.format( - len(hosts), '\n'.join(sorted(hosts)))) + 'Available hosts:\n{}'.format(len(hosts), + '\n'.join(sorted(hosts)))) util.sysexit_with_message(msg) match = [x for x in hosts if x.startswith(hostname)] if len(match) == 0: @@ -128,8 +128,8 @@ def _get_hostname(self, hosts): else: msg = ("There are {} hosts that match '{}'. You " 'can only login to one at a time.\n\n' - 'Available hosts:\n{}'.format( - len(match), hostname, '\n'.join(sorted(hosts)))) + 'Available hosts:\n{}'.format(len(match), hostname, + '\n'.join(sorted(hosts)))) util.sysexit_with_message(msg) return match[0] @@ -161,12 +161,11 @@ def _sigwinch_passthrough(self, sig, data): # pragma: no cover @click.command() @click.pass_context @click.option('--host', '-h', help='Host to access.') -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) def login(ctx, host, scenario_name): # pragma: no cover """ Log in to one instance. """ args = ctx.obj.get('args') @@ -176,7 +175,7 @@ def login(ctx, host, scenario_name): # pragma: no cover 'host': host, } - s = scenarios.Scenarios( - base.get_configs(args, command_args), scenario_name) + s = scenarios.Scenarios(base.get_configs(args, command_args), + scenario_name) for scenario in s.all: base.execute_subcommand(scenario.config, subcommand) diff --git a/molecule/command/matrix.py b/molecule/command/matrix.py index c9c176758e..5e4a3e6cc8 100644 --- a/molecule/command/matrix.py +++ b/molecule/command/matrix.py @@ -78,6 +78,6 @@ def matrix(ctx, scenario_name, subcommand): # pragma: no cover 'subcommand': subcommand, } - s = scenarios.Scenarios( - base.get_configs(args, command_args), scenario_name) + s = scenarios.Scenarios(base.get_configs(args, command_args), + scenario_name) s.print_matrix() diff --git a/molecule/command/prepare.py b/molecule/command/prepare.py index 1421d26519..9a7d6346d5 100644 --- a/molecule/command/prepare.py +++ b/molecule/command/prepare.py @@ -105,21 +105,18 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) -@click.option( - '--driver-name', - '-d', - type=click.Choice(config.molecule_drivers()), - help='Name of driver to use. (docker)') -@click.option( - '--force/--no-force', - default=False, - help='Enable or disable force mode. Default is disabled.') +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--driver-name', + '-d', + type=click.Choice(config.molecule_drivers()), + help='Name of driver to use. (docker)') +@click.option('--force/--no-force', + default=False, + help='Enable or disable force mode. Default is disabled.') def prepare(ctx, scenario_name, driver_name, force): # pragma: no cover """ Use the provisioner to prepare the instances into a particular starting diff --git a/molecule/command/side_effect.py b/molecule/command/side_effect.py index 40025a107a..aab8f5f9de 100644 --- a/molecule/command/side_effect.py +++ b/molecule/command/side_effect.py @@ -81,12 +81,11 @@ def execute(self): @click.command(name='side-effect') @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) def side_effect(ctx, scenario_name): # pragma: no cover """ Use the provisioner to perform side-effects to the instances. """ args = ctx.obj.get('args') diff --git a/molecule/command/syntax.py b/molecule/command/syntax.py index bf83548b6c..79955aab76 100644 --- a/molecule/command/syntax.py +++ b/molecule/command/syntax.py @@ -73,12 +73,11 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) def syntax(ctx, scenario_name): # pragma: no cover """ Use the provisioner to syntax check the role. """ args = ctx.obj.get('args') diff --git a/molecule/command/test.py b/molecule/command/test.py index 7db0cd8796..b82d88b629 100644 --- a/molecule/command/test.py +++ b/molecule/command/test.py @@ -84,28 +84,24 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) -@click.option( - '--driver-name', - '-d', - type=click.Choice(config.molecule_drivers()), - help='Name of driver to use. (docker)') -@click.option( - '--all/--no-all', - '__all', - default=False, - help='Test all scenarios. Default is False.') -@click.option( - '--destroy', - type=click.Choice(['always', 'never']), - default='always', - help=('The destroy strategy used at the conclusion of a ' - 'Molecule run (always).')) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--driver-name', + '-d', + type=click.Choice(config.molecule_drivers()), + help='Name of driver to use. (docker)') +@click.option('--all/--no-all', + '__all', + default=False, + help='Test all scenarios. Default is False.') +@click.option('--destroy', + type=click.Choice(['always', 'never']), + default='always', + help=('The destroy strategy used at the conclusion of a ' + 'Molecule run (always).')) def test(ctx, scenario_name, driver_name, __all, destroy): # pragma: no cover """ Test (lint, cleanup, destroy, dependency, syntax, create, prepare, diff --git a/molecule/command/verify.py b/molecule/command/verify.py index a6c5ef1ce8..6a71fa5cae 100644 --- a/molecule/command/verify.py +++ b/molecule/command/verify.py @@ -73,12 +73,11 @@ def execute(self): @click.command() @click.pass_context -@click.option( - '--scenario-name', - '-s', - default=base.MOLECULE_DEFAULT_SCENARIO_NAME, - help='Name of the scenario to target. ({})'.format( - base.MOLECULE_DEFAULT_SCENARIO_NAME)) +@click.option('--scenario-name', + '-s', + default=base.MOLECULE_DEFAULT_SCENARIO_NAME, + help='Name of the scenario to target. ({})'.format( + base.MOLECULE_DEFAULT_SCENARIO_NAME)) def verify(ctx, scenario_name): # pragma: no cover """ Run automated tests against instances. """ args = ctx.obj.get('args') diff --git a/molecule/dependency/ansible_galaxy.py b/molecule/dependency/ansible_galaxy.py index ddb5a77f69..b12d03bdf5 100644 --- a/molecule/dependency/ansible_galaxy.py +++ b/molecule/dependency/ansible_galaxy.py @@ -121,13 +121,12 @@ def bake(self): verbose_flag = util.verbose_flag(options) self._sh_command = getattr(sh, self.command) - self._sh_command = self._sh_command.bake( - 'install', - options, - *verbose_flag, - _env=self.env, - _out=LOG.out, - _err=LOG.error) + self._sh_command = self._sh_command.bake('install', + options, + *verbose_flag, + _env=self.env, + _out=LOG.out, + _err=LOG.error) def execute(self): if not self.enabled: diff --git a/molecule/dependency/gilt.py b/molecule/dependency/gilt.py index 10bc14bf94..85de61467e 100644 --- a/molecule/dependency/gilt.py +++ b/molecule/dependency/gilt.py @@ -90,12 +90,11 @@ def bake(self): :return: None """ self._sh_command = getattr(sh, self.command) - self._sh_command = self._sh_command.bake( - self.options, - 'overlay', - _env=self.env, - _out=LOG.out, - _err=LOG.error) + self._sh_command = self._sh_command.bake(self.options, + 'overlay', + _env=self.env, + _out=LOG.out, + _err=LOG.error) def execute(self): if not self.enabled: diff --git a/molecule/dependency/shell.py b/molecule/dependency/shell.py index e5fed5c262..8c04902f67 100644 --- a/molecule/dependency/shell.py +++ b/molecule/dependency/shell.py @@ -98,8 +98,10 @@ def bake(self): self._sh_command = getattr(sh, command) # Reconstruct command with remaining args. - self._sh_command = self._sh_command.bake( - args, _env=self.env, _out=LOG.out, _err=LOG.error) + self._sh_command = self._sh_command.bake(args, + _env=self.env, + _out=LOG.out, + _err=LOG.error) def execute(self): if not self.enabled: diff --git a/molecule/driver/linode.py b/molecule/driver/linode.py index cead0b9273..c301ea076d 100644 --- a/molecule/driver/linode.py +++ b/molecule/driver/linode.py @@ -144,11 +144,10 @@ def _get_instance_config(self, instance_name): instance_config_dict = util.safe_load_file( self._config.driver.instance_config) - return next( - item for item in instance_config_dict if any(( - # NOTE(lwm): Handle both because of transitioning label logic - # https://github.com/ansible/ansible/pull/44719 - item['instance'] == '{}_{}'.format(item['linode_id'], - instance_name), - item['instance'] == '{}-{}'.format(item['linode_id'], - instance_name)))) + return next(item for item in instance_config_dict if any(( + # NOTE(lwm): Handle both because of transitioning label logic + # https://github.com/ansible/ansible/pull/44719 + item['instance'] == '{}_{}'.format(item['linode_id'], + instance_name), + item['instance'] == '{}-{}'.format(item['linode_id'], + instance_name)))) diff --git a/molecule/lint/yamllint.py b/molecule/lint/yamllint.py index c9613815e3..8a4a9b9162 100644 --- a/molecule/lint/yamllint.py +++ b/molecule/lint/yamllint.py @@ -113,12 +113,11 @@ def bake(self): :return: None """ - self._yamllint_command = sh.yamllint.bake( - self.options, - self._files, - _env=self.env, - _out=LOG.out, - _err=LOG.error) + self._yamllint_command = sh.yamllint.bake(self.options, + self._files, + _env=self.env, + _out=LOG.out, + _err=LOG.error) def execute(self): if not self.enabled: diff --git a/molecule/migrate.py b/molecule/migrate.py index b9c60e37f9..eeda3e0b7b 100644 --- a/molecule/migrate.py +++ b/molecule/migrate.py @@ -54,12 +54,11 @@ def dump(self): yaml.add_representer(collections.OrderedDict, self._get_dict_representer) - return yaml.dump( - od, - Dumper=MyDumper, - default_flow_style=False, - explicit_start=True, - line_break=1) + return yaml.dump(od, + Dumper=MyDumper, + default_flow_style=False, + explicit_start=True, + line_break=1) def _convert(self): if self._v1.get('vagrant'): diff --git a/molecule/model/schema_v2.py b/molecule/model/schema_v2.py index ec1df97e1b..d9f696b3d5 100644 --- a/molecule/model/schema_v2.py +++ b/molecule/model/schema_v2.py @@ -75,8 +75,8 @@ def pre_validate_base_schema(env, keep_string): # NOTE(retr0h): Some users use an environment variable to # change the driver name. May add this coercion to rest of # config using allowed validation. - 'coerce': (str, - functools.partial(coerce_env, env, keep_string)) + 'coerce': + (str, functools.partial(coerce_env, env, keep_string)) }, } }, diff --git a/molecule/provisioner/ansible.py b/molecule/provisioner/ansible.py index 62f720921a..4881d69f67 100644 --- a/molecule/provisioner/ansible.py +++ b/molecule/provisioner/ansible.py @@ -587,9 +587,9 @@ def playbooks(self): @property def directory(self): - return os.path.join( - os.path.dirname(__file__), os.path.pardir, os.path.pardir, - 'molecule', 'provisioner', 'ansible') + return os.path.join(os.path.dirname(__file__), os.path.pardir, + os.path.pardir, 'molecule', 'provisioner', + 'ansible') def cleanup(self): """ @@ -702,8 +702,8 @@ def write_config(self): :return: None """ - template = util.render_template( - self._get_config_template(), config_options=self.config_options) + template = util.render_template(self._get_config_template(), + config_options=self.config_options) util.write_file(self.config_file, template) def manage_inventory(self): @@ -757,8 +757,8 @@ def _add_or_update_vars(self): for target in vars_target.keys(): target_var_content = vars_target[target] - path = os.path.join( - util.abs_path(target_vars_directory), target) + path = os.path.join(util.abs_path(target_vars_directory), + target) util.write_file(path, util.safe_dump(target_var_content)) def _write_inventory(self): diff --git a/molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py b/molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py index 7a0687fa92..6c79a3cfa4 100644 --- a/molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py +++ b/molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py @@ -401,10 +401,9 @@ def up(self): # NOTE(retr0h): Ansible wants only one module return `fail_json` # or `exit_json`. if not self._has_error: - self._module.exit_json( - changed=changed, - log=self._get_stdout_log(), - **self._conf()) + self._module.exit_json(changed=changed, + log=self._get_stdout_log(), + **self._conf()) else: msg = "ERROR: See log file '{}'".format(self._get_stderr_log()) self._module.fail_json(msg=msg) @@ -471,8 +470,9 @@ def _write_configs(self): def _get_vagrant(self): env = os.environ.copy() env['VAGRANT_CWD'] = os.environ['MOLECULE_EPHEMERAL_DIRECTORY'] - v = vagrant.Vagrant( - out_cm=self.stdout_cm, err_cm=self.stderr_cm, env=env) + v = vagrant.Vagrant(out_cm=self.stdout_cm, + err_cm=self.stderr_cm, + env=env) return v @@ -537,24 +537,28 @@ def _get_vagrant_log(self, __type): def main(): module = AnsibleModule( # noqa - argument_spec=dict( - instance_name=dict(type='str', required=True), - instance_interfaces=dict(type='list', default=[]), - instance_raw_config_args=dict(type='list', default=None), - config_options=dict(type='dict', default={}), - platform_box=dict(type='str', required=False), - platform_box_version=dict(type='str'), - platform_box_url=dict(type='str'), - provider_name=dict(type='str', default='virtualbox'), - provider_memory=dict(type='int', default=512), - provider_cpus=dict(type='int', default=2), - provider_options=dict(type='dict', default={}), - provider_override_args=dict(type='list', default=None), - provider_raw_config_args=dict(type='list', default=None), - provision=dict(type='bool', default=False), - force_stop=dict(type='bool', default=False), - state=dict( - type='str', default='up', choices=['up', 'destroy', 'halt'])), + argument_spec=dict(instance_name=dict(type='str', required=True), + instance_interfaces=dict(type='list', default=[]), + instance_raw_config_args=dict(type='list', + default=None), + config_options=dict(type='dict', default={}), + platform_box=dict(type='str', required=False), + platform_box_version=dict(type='str'), + platform_box_url=dict(type='str'), + provider_name=dict(type='str', + default='virtualbox'), + provider_memory=dict(type='int', default=512), + provider_cpus=dict(type='int', default=2), + provider_options=dict(type='dict', default={}), + provider_override_args=dict(type='list', + default=None), + provider_raw_config_args=dict(type='list', + default=None), + provision=dict(type='bool', default=False), + force_stop=dict(type='bool', default=False), + state=dict(type='str', + default='up', + choices=['up', 'destroy', 'halt'])), supports_check_mode=False) v = VagrantClient(module) diff --git a/molecule/provisioner/ansible_playbook.py b/molecule/provisioner/ansible_playbook.py index df6820c71c..805eda1b8e 100644 --- a/molecule/provisioner/ansible_playbook.py +++ b/molecule/provisioner/ansible_playbook.py @@ -89,8 +89,8 @@ def execute(self): self.bake() try: - cmd = util.run_command( - self._ansible_command, debug=self._config.debug) + cmd = util.run_command(self._ansible_command, + debug=self._config.debug) return cmd.stdout.decode('utf-8') except sh.ErrorReturnCode as e: out = e.stdout.decode('utf-8') diff --git a/molecule/provisioner/lint/ansible_lint.py b/molecule/provisioner/lint/ansible_lint.py index 10091ac313..04fe453b95 100644 --- a/molecule/provisioner/lint/ansible_lint.py +++ b/molecule/provisioner/lint/ansible_lint.py @@ -146,8 +146,8 @@ def execute(self): LOG.info(msg) try: - util.run_command( - self._ansible_lint_command, debug=self._config.debug) + util.run_command(self._ansible_lint_command, + debug=self._config.debug) msg = 'Lint completed successfully.' LOG.success(msg) except sh.ErrorReturnCode as e: diff --git a/molecule/scenario.py b/molecule/scenario.py index 3a3647245d..826fb713fc 100644 --- a/molecule/scenario.py +++ b/molecule/scenario.py @@ -118,8 +118,8 @@ def prune(self): os.remove(f) # Remove empty directories. - for dirpath, dirs, files in os.walk( - self.ephemeral_directory, topdown=False): + for dirpath, dirs, files in os.walk(self.ephemeral_directory, + topdown=False): if not dirs and not files: os.removedirs(dirpath) @@ -135,8 +135,9 @@ def directory(self): def ephemeral_directory(self): project_directory = os.path.basename(self.config.project_directory) scenario_name = self.name - project_scenario_directory = os.path.join( - 'molecule', project_directory, scenario_name) + project_scenario_directory = os.path.join('molecule', + project_directory, + scenario_name) path = ephemeral_directory(project_scenario_directory) return ephemeral_directory(path) diff --git a/molecule/scenarios.py b/molecule/scenarios.py index 00c274a8d7..2ef3bb89c4 100644 --- a/molecule/scenarios.py +++ b/molecule/scenarios.py @@ -81,10 +81,9 @@ def print_matrix(self): for action in scenario.sequence]) for scenario in self.all])) - tf = tree_format.format_tree( - tree, - format_node=operator.itemgetter(0), - get_children=operator.itemgetter(1)) + tf = tree_format.format_tree(tree, + format_node=operator.itemgetter(0), + get_children=operator.itemgetter(1)) LOG.out(tf) LOG.out('') diff --git a/molecule/shell.py b/molecule/shell.py index 79a3efada4..da06038f33 100644 --- a/molecule/shell.py +++ b/molecule/shell.py @@ -86,18 +86,16 @@ def _allowed(ctx, param, value): # pragma: no cover @click.group() -@click.option( - '--debug/--no-debug', - default=MOLECULE_DEBUG, - callback=_allowed, - help='Enable or disable debug mode. Default is disabled.') -@click.option( - '--base-config', - '-c', - default=LOCAL_CONFIG, - help=('Path to a base config. If provided Molecule will load ' - "this config first, and deep merge each scenario's " - 'molecule.yml on top. ({})').format(LOCAL_CONFIG)) +@click.option('--debug/--no-debug', + default=MOLECULE_DEBUG, + callback=_allowed, + help='Enable or disable debug mode. Default is disabled.') +@click.option('--base-config', + '-c', + default=LOCAL_CONFIG, + help=('Path to a base config. If provided Molecule will load ' + "this config first, and deep merge each scenario's " + 'molecule.yml on top. ({})').format(LOCAL_CONFIG)) @click.option( '--env-file', '-e', diff --git a/molecule/util.py b/molecule/util.py index 34246afd08..cc35a11d92 100644 --- a/molecule/util.py +++ b/molecule/util.py @@ -162,8 +162,10 @@ def safe_dump(data): # TODO(retr0h): Do we need to encode? # yaml.dump(data) produces the document as a str object in both python # 2 and 3. - return yaml.dump( - data, Dumper=SafeDumper, default_flow_style=False, explicit_start=True) + return yaml.dump(data, + Dumper=SafeDumper, + default_flow_style=False, + explicit_start=True) def safe_load(string): diff --git a/molecule/verifier/lint/flake8.py b/molecule/verifier/lint/flake8.py index ee9edf9363..4e7d8b42fe 100644 --- a/molecule/verifier/lint/flake8.py +++ b/molecule/verifier/lint/flake8.py @@ -97,12 +97,11 @@ def bake(self): :return: None """ - self._flake8_command = sh.flake8.bake( - self.options, - self._tests, - _env=self.env, - _out=LOG.out, - _err=LOG.error) + self._flake8_command = sh.flake8.bake(self.options, + self._tests, + _env=self.env, + _out=LOG.out, + _err=LOG.error) def execute(self): if not self.enabled: diff --git a/molecule/verifier/lint/rubocop.py b/molecule/verifier/lint/rubocop.py index 9b955c612e..b19174c1fc 100644 --- a/molecule/verifier/lint/rubocop.py +++ b/molecule/verifier/lint/rubocop.py @@ -101,12 +101,11 @@ def bake(self): :return: None """ - self._rubocop_command = sh.rubocop.bake( - self.options, - self._tests, - _env=self.env, - _out=LOG.out, - _err=LOG.error) + self._rubocop_command = sh.rubocop.bake(self.options, + self._tests, + _env=self.env, + _out=LOG.out, + _err=LOG.error) def execute(self): if not self.enabled: diff --git a/molecule/verifier/lint/yamllint.py b/molecule/verifier/lint/yamllint.py index cd44c04026..a7edc272dd 100644 --- a/molecule/verifier/lint/yamllint.py +++ b/molecule/verifier/lint/yamllint.py @@ -99,12 +99,11 @@ def bake(self): :return: None """ - self._yamllint_command = sh.yamllint.bake( - self.options, - self._tests, - _env=self.env, - _out=LOG.out, - _err=LOG.error) + self._yamllint_command = sh.yamllint.bake(self.options, + self._tests, + _env=self.env, + _out=LOG.out, + _err=LOG.error) def execute(self): if not self.enabled: diff --git a/test/conftest.py b/test/conftest.py index 5b006b8378..2a0b2564fa 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -103,8 +103,9 @@ def molecule_ephemeral_directory(): def pytest_addoption(parser): - parser.addoption( - '--delegated', action='store_true', help='Run delegated driver tests.') + parser.addoption('--delegated', + action='store_true', + help='Run delegated driver tests.') def pytest_collection_modifyitems(items): diff --git a/test/functional/conftest.py b/test/functional/conftest.py index 2bafec09d5..bb0a5d7813 100644 --- a/test/functional/conftest.py +++ b/test/functional/conftest.py @@ -48,9 +48,9 @@ def _env_vars_exposed(env_vars, env=os.environ): @pytest.fixture def with_scenario(request, scenario_to_test, driver_name, scenario_name, skip_test): - scenario_directory = os.path.join( - os.path.dirname(util.abs_path(__file__)), os.path.pardir, 'scenarios', - scenario_to_test) + scenario_directory = os.path.join(os.path.dirname(util.abs_path(__file__)), + os.path.pardir, 'scenarios', + scenario_to_test) with change_dir_to(scenario_directory): yield @@ -171,8 +171,8 @@ def metadata_lint_update(role_directory): # users should receive feedback to change these defaults. However, this # blocks the testing of 'molecule init' itself, so ansible-lint should # be configured to ignore these metadata lint errors. - ansible_lint_src = os.path.join( - os.path.dirname(util.abs_path(__file__)), '.ansible-lint') + ansible_lint_src = os.path.join(os.path.dirname(util.abs_path(__file__)), + '.ansible-lint') shutil.copy(ansible_lint_src, role_directory) # Explicitly lint here to catch any unexpected lint errors before diff --git a/test/functional/docker/test_scenarios.py b/test/functional/docker/test_scenarios.py index 422e801985..e460734fd0 100644 --- a/test/functional/docker/test_scenarios.py +++ b/test/functional/docker/test_scenarios.py @@ -54,15 +54,14 @@ def driver_name(request): @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('side_effect', 'docker', 'default'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('side_effect', 'docker', 'default'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_side_effect(scenario_to_test, with_scenario, scenario_name): options = { 'driver_name': 'docker', @@ -73,15 +72,14 @@ def test_command_side_effect(scenario_to_test, with_scenario, scenario_name): @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('cleanup', 'docker', 'default'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('cleanup', 'docker', 'default'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_cleanup(scenario_to_test, with_scenario, scenario_name): options = { 'driver_name': 'docker', @@ -265,15 +263,14 @@ def test_command_init_role_with_template(temp_dir): @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('overrride_driver', 'docker', 'default'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('overrride_driver', 'docker', 'default'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_test_overrides_driver(scenario_to_test, with_scenario, driver_name, scenario_name): options = { @@ -285,17 +282,17 @@ def test_command_test_overrides_driver(scenario_to_test, with_scenario, @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('driver/docker', 'docker', 'default'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) -def test_command_test_builds_local_molecule_image( - scenario_to_test, with_scenario, scenario_name, driver_name): +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('driver/docker', 'docker', 'default'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) +def test_command_test_builds_local_molecule_image(scenario_to_test, + with_scenario, scenario_name, + driver_name): try: cmd = sh.docker.bake('rmi', 'molecule_local/centos:latest', '--force') pytest.helpers.run_command(cmd) @@ -306,15 +303,14 @@ def test_command_test_builds_local_molecule_image( @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('test_destroy_strategy', 'docker', 'default'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('test_destroy_strategy', 'docker', 'default'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_test_destroy_strategy_always(scenario_to_test, with_scenario, scenario_name, driver_name): options = { @@ -334,15 +330,14 @@ def test_command_test_destroy_strategy_always(scenario_to_test, with_scenario, @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('test_destroy_strategy', 'docker', 'default'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('test_destroy_strategy', 'docker', 'default'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_test_destroy_strategy_never(scenario_to_test, with_scenario, scenario_name, driver_name): options = { @@ -360,15 +355,14 @@ def test_command_test_destroy_strategy_never(scenario_to_test, with_scenario, @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('host_group_vars', 'docker', 'default'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('host_group_vars', 'docker', 'default'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_host_group_vars(scenario_to_test, with_scenario, scenario_name): options = { 'all': True, @@ -383,15 +377,14 @@ def test_host_group_vars(scenario_to_test, with_scenario, scenario_name): @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('idempotence', 'docker', 'raises'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('idempotence', 'docker', 'raises'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_idempotence_raises(scenario_to_test, with_scenario, scenario_name): options = { 'scenario_name': scenario_name, @@ -406,15 +399,14 @@ def test_idempotence_raises(scenario_to_test, with_scenario, scenario_name): @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('interpolation', 'docker', 'default'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('interpolation', 'docker', 'default'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_interpolation(scenario_to_test, with_scenario, scenario_name): # Modify global environment so cleanup inherits our environment. options = { @@ -431,15 +423,14 @@ def test_interpolation(scenario_to_test, with_scenario, scenario_name): @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('verifier', 'docker', 'testinfra'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('verifier', 'docker', 'testinfra'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_verify_testinfra(scenario_to_test, with_scenario, scenario_name): options = { @@ -462,15 +453,14 @@ def test_command_verify_testinfra(scenario_to_test, with_scenario, @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('verifier', 'docker', 'goss'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('verifier', 'docker', 'goss'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_verify_goss(scenario_to_test, with_scenario, scenario_name): options = { 'scenario_name': scenario_name, @@ -492,15 +482,14 @@ def test_command_verify_goss(scenario_to_test, with_scenario, scenario_name): @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('verifier', 'docker', 'inspec'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('verifier', 'docker', 'inspec'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_verify_inspec(scenario_to_test, with_scenario, scenario_name): options = { 'scenario_name': scenario_name, @@ -522,15 +511,14 @@ def test_command_verify_inspec(scenario_to_test, with_scenario, scenario_name): @skip_unsupported_matrix -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('plugins', 'docker', 'default'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('plugins', 'docker', 'default'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_plugins(scenario_to_test, with_scenario, scenario_name): options = { 'scenario_name': scenario_name, diff --git a/test/functional/test_command.py b/test/functional/test_command.py index 4b74413ccd..510c775c60 100644 --- a/test/functional/test_command.py +++ b/test/functional/test_command.py @@ -169,24 +169,23 @@ def test_command_create(scenario_to_test, with_scenario, scenario_name): pytest.helpers.run_command(cmd) -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('dependency', 'azure', 'ansible-galaxy'), - ('dependency', 'digitalocean', 'ansible-galaxy'), - ('dependency', 'docker', 'ansible-galaxy'), - ('dependency', 'ec2', 'ansible-galaxy'), - ('dependency', 'gce', 'ansible-galaxy'), - ('dependency', 'linode', 'ansible-galaxy'), - ('dependency', 'lxc', 'ansible-galaxy'), - ('dependency', 'lxd', 'ansible-galaxy'), - ('dependency', 'openstack', 'ansible-galaxy'), - ('dependency', 'vagrant', 'ansible-galaxy'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('dependency', 'azure', 'ansible-galaxy'), + ('dependency', 'digitalocean', 'ansible-galaxy'), + ('dependency', 'docker', 'ansible-galaxy'), + ('dependency', 'ec2', 'ansible-galaxy'), + ('dependency', 'gce', 'ansible-galaxy'), + ('dependency', 'linode', 'ansible-galaxy'), + ('dependency', 'lxc', 'ansible-galaxy'), + ('dependency', 'lxd', 'ansible-galaxy'), + ('dependency', 'openstack', 'ansible-galaxy'), + ('dependency', 'vagrant', 'ansible-galaxy'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_dependency_ansible_galaxy(request, scenario_to_test, with_scenario, scenario_name): # FIXME(decentral1se): skipped due to failures on network access @@ -203,24 +202,23 @@ def test_command_dependency_ansible_galaxy(request, scenario_to_test, assert os.path.isdir(dependency_role) -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('dependency', 'azure', 'gilt'), - ('dependency', 'digitalocean', 'gilt'), - ('dependency', 'docker', 'gilt'), - ('dependency', 'ec2', 'gilt'), - ('dependency', 'gce', 'gilt'), - ('dependency', 'linode', 'gilt'), - ('dependency', 'lxc', 'gilt'), - ('dependency', 'lxd', 'gilt'), - ('dependency', 'openstack', 'gilt'), - ('dependency', 'vagrant', 'gilt'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('dependency', 'azure', 'gilt'), + ('dependency', 'digitalocean', 'gilt'), + ('dependency', 'docker', 'gilt'), + ('dependency', 'ec2', 'gilt'), + ('dependency', 'gce', 'gilt'), + ('dependency', 'linode', 'gilt'), + ('dependency', 'lxc', 'gilt'), + ('dependency', 'lxd', 'gilt'), + ('dependency', 'openstack', 'gilt'), + ('dependency', 'vagrant', 'gilt'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_dependency_gilt(request, scenario_to_test, with_scenario, scenario_name): # FIXME(decentral1se): skipped due to failures on network access @@ -236,24 +234,23 @@ def test_command_dependency_gilt(request, scenario_to_test, with_scenario, assert os.path.isdir(dependency_role) -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, scenario_name', [ - ('dependency', 'azure', 'shell'), - ('dependency', 'digitalocean', 'shell'), - ('dependency', 'docker', 'shell'), - ('dependency', 'ec2', 'shell'), - ('dependency', 'gce', 'shell'), - ('dependency', 'linode', 'shell'), - ('dependency', 'lxc', 'shell'), - ('dependency', 'lxd', 'shell'), - ('dependency', 'openstack', 'shell'), - ('dependency', 'vagrant', 'shell'), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - 'scenario_name', - ]) +@pytest.mark.parametrize('scenario_to_test, driver_name, scenario_name', [ + ('dependency', 'azure', 'shell'), + ('dependency', 'digitalocean', 'shell'), + ('dependency', 'docker', 'shell'), + ('dependency', 'ec2', 'shell'), + ('dependency', 'gce', 'shell'), + ('dependency', 'linode', 'shell'), + ('dependency', 'lxc', 'shell'), + ('dependency', 'lxd', 'shell'), + ('dependency', 'openstack', 'shell'), + ('dependency', 'vagrant', 'shell'), +], + indirect=[ + 'scenario_to_test', + 'driver_name', + 'scenario_name', + ]) def test_command_dependency_shell(request, scenario_to_test, with_scenario, scenario_name): # FIXME(decentral1se): skipped due to failures on network access @@ -329,42 +326,40 @@ def test_command_idempotence(scenario_to_test, with_scenario, scenario_name): pytest.helpers.idempotence(scenario_name) -@pytest.mark.parametrize( - 'driver_name', [ - ('azure'), - ('digitalocean'), - ('docker'), - ('ec2'), - ('gce'), - ('linode'), - ('lxc'), - ('lxd'), - ('openstack'), - ('vagrant'), - ], - indirect=[ - 'driver_name', - ]) +@pytest.mark.parametrize('driver_name', [ + ('azure'), + ('digitalocean'), + ('docker'), + ('ec2'), + ('gce'), + ('linode'), + ('lxc'), + ('lxd'), + ('openstack'), + ('vagrant'), +], + indirect=[ + 'driver_name', + ]) def test_command_init_role(temp_dir, driver_name, skip_test): pytest.helpers.init_role(temp_dir, driver_name) -@pytest.mark.parametrize( - 'driver_name', [ - ('azure'), - ('digitalocean'), - ('docker'), - ('ec2'), - ('gce'), - ('linode'), - ('lxc'), - ('lxd'), - ('openstack'), - ('vagrant'), - ], - indirect=[ - 'driver_name', - ]) +@pytest.mark.parametrize('driver_name', [ + ('azure'), + ('digitalocean'), + ('docker'), + ('ec2'), + ('gce'), + ('linode'), + ('lxc'), + ('lxd'), + ('openstack'), + ('vagrant'), +], + indirect=[ + 'driver_name', + ]) def test_command_init_scenario(temp_dir, driver_name, skip_test): pytest.helpers.init_scenario(temp_dir, driver_name) @@ -492,70 +487,69 @@ def test_command_list(scenario_to_test, with_scenario, expected): pytest.helpers.list(expected) -@pytest.mark.parametrize( - 'scenario_to_test, driver_name, expected', [ - ('driver/azure', 'azure', """ +@pytest.mark.parametrize('scenario_to_test, driver_name, expected', [ + ('driver/azure', 'azure', """ instance azure ansible default false false instance-1 azure ansible multi-node false false instance-2 azure ansible multi-node false false """.strip()), - ('driver/digitalocean', 'digitalocean', """ + ('driver/digitalocean', 'digitalocean', """ instance digitalocean ansible default false false instance-1 digitalocean ansible multi-node false false instance-2 digitalocean ansible multi-node false false """.strip()), - ('driver/docker', 'docker', """ + ('driver/docker', 'docker', """ instance docker ansible default false false instance-1 docker ansible multi-node false false instance-2 docker ansible multi-node false false """.strip()), - ('driver/ec2', 'ec2', """ + ('driver/ec2', 'ec2', """ instance ec2 ansible default false false instance-1 ec2 ansible multi-node false false instance-2 ec2 ansible multi-node false false """.strip()), - ('driver/gce', 'gce', """ + ('driver/gce', 'gce', """ instance gce ansible default false false instance-1 gce ansible multi-node false false instance-2 gce ansible multi-node false false """.strip()), - ('driver/linode', 'linode', """ + ('driver/linode', 'linode', """ instance linode ansible default false false instance-1 linode ansible multi-node false false instance-2 linode ansible multi-node false false """.strip()), - ('driver/lxc', 'lxc', """ + ('driver/lxc', 'lxc', """ instance lxc ansible default false false instance-1 lxc ansible multi-node false false instance-2 lxc ansible multi-node false false """.strip()), - ('driver/lxd', 'lxd', """ + ('driver/lxd', 'lxd', """ instance lxd ansible default false false instance-1 lxd ansible multi-node false false instance-2 lxd ansible multi-node false false """.strip()), - ('driver/openstack', 'openstack', """ + ('driver/openstack', 'openstack', """ instance openstack ansible default false false instance-1 openstack ansible multi-node false false instance-2 openstack ansible multi-node false false """.strip()), - ('driver/delegated', 'delegated', """ + ('driver/delegated', 'delegated', """ delegated-instance-docker delegated ansible docker unknown true delegated-instance-ec2 delegated ansible ec2 unknown true delegated-instance-gce delegated ansible gce unknown true delegated-instance-openstack delegated ansible openstack unknown true delegated-instance-vagrant delegated ansible vagrant unknown false """.strip()), - ('driver/vagrant', 'vagrant', """ + ('driver/vagrant', 'vagrant', """ instance vagrant ansible default false false instance-1 vagrant ansible multi-node false false instance-2 vagrant ansible multi-node false false """.strip()), - ], - indirect=[ - 'scenario_to_test', - 'driver_name', - ]) +], + indirect=[ + 'scenario_to_test', + 'driver_name', + ]) def test_command_list_with_format_plain(scenario_to_test, with_scenario, expected): pytest.helpers.list_with_format_plain(expected) diff --git a/test/resources/roles/testplugin/library/library.py b/test/resources/roles/testplugin/library/library.py index 0241f7d5f3..887ed88014 100644 --- a/test/resources/roles/testplugin/library/library.py +++ b/test/resources/roles/testplugin/library/library.py @@ -25,9 +25,9 @@ def main(): - module = AnsibleModule( - argument_spec=dict(name=dict(type='str', required=False), ), - supports_check_mode=False) + module = AnsibleModule(argument_spec=dict(name=dict(type='str', + required=False), ), + supports_check_mode=False) ansible_facts_dict = { 'changed': False, diff --git a/test/unit/command/test_base.py b/test/unit/command/test_base.py index f08bd2eb3e..b2ab725606 100644 --- a/test/unit/command/test_base.py +++ b/test/unit/command/test_base.py @@ -137,9 +137,11 @@ def test_execute_cmdline_scenarios(config_instance, _patched_print_matrix, assert _patched_execute_scenario.call_count == 1 -def test_execute_cmdline_scenarios_destroy( - config_instance, _patched_execute_scenario, _patched_prune, - _patched_execute_subcommand, _patched_sysexit): +def test_execute_cmdline_scenarios_destroy(config_instance, + _patched_execute_scenario, + _patched_prune, + _patched_execute_subcommand, + _patched_sysexit): # Ensure execute_cmdline_scenarios handles errors correctly when 'destroy' # is 'always': # - cleanup and destroy subcommands are run when execute_scenario diff --git a/test/unit/command/test_cleanup.py b/test/unit/command/test_cleanup.py index 946d8a7bbf..c28db11a6b 100644 --- a/test/unit/command/test_cleanup.py +++ b/test/unit/command/test_cleanup.py @@ -46,9 +46,9 @@ def _patched_ansible_cleanup(mocker): # NOTE(retr0h): The use of the `patched_config_validate` fixture, disables # config.Config._validate from executing. Thus preventing odd side-effects # throughout patched.assert_called unit tests. -@pytest.mark.parametrize( - 'config_instance', ['_command_provisioner_section_with_cleanup_data'], - indirect=True) +@pytest.mark.parametrize('config_instance', + ['_command_provisioner_section_with_cleanup_data'], + indirect=True) def test_execute(mocker, _patched_ansible_cleanup, patched_logger_info, patched_config_validate, config_instance): pb = os.path.join(config_instance.scenario.directory, 'cleanup.yml') @@ -66,8 +66,9 @@ def test_execute(mocker, _patched_ansible_cleanup, patched_logger_info, _patched_ansible_cleanup.assert_called_once_with() -def test_execute_skips_when_playbook_not_configured( - patched_logger_warn, _patched_ansible_cleanup, config_instance): +def test_execute_skips_when_playbook_not_configured(patched_logger_warn, + _patched_ansible_cleanup, + config_instance): cu = cleanup.Cleanup(config_instance) cu.execute() diff --git a/test/unit/command/test_create.py b/test/unit/command/test_create.py index 70501eea15..2ce4b62906 100644 --- a/test/unit/command/test_create.py +++ b/test/unit/command/test_create.py @@ -49,12 +49,13 @@ def test_execute(mocker, patched_logger_info, command_patched_ansible_create, assert config_instance.state.created -@pytest.mark.parametrize( - 'config_instance', ['command_driver_delegated_section_data'], - indirect=True) -def test_execute_skips_when_delegated_driver( - _patched_create_setup, patched_logger_warn, - command_patched_ansible_create, config_instance): +@pytest.mark.parametrize('config_instance', + ['command_driver_delegated_section_data'], + indirect=True) +def test_execute_skips_when_delegated_driver(_patched_create_setup, + patched_logger_warn, + command_patched_ansible_create, + config_instance): c = create.Create(config_instance) c.execute() diff --git a/test/unit/command/test_destroy.py b/test/unit/command/test_destroy.py index 78b178a554..0fde099aca 100644 --- a/test/unit/command/test_destroy.py +++ b/test/unit/command/test_destroy.py @@ -53,12 +53,13 @@ def test_execute(mocker, patched_logger_info, patched_config_validate, assert not config_instance.state.created -@pytest.mark.parametrize( - 'config_instance', ['command_driver_delegated_section_data'], - indirect=True) -def test_execute_skips_when_destroy_strategy_is_never( - _patched_destroy_setup, patched_logger_warn, _patched_ansible_destroy, - config_instance): +@pytest.mark.parametrize('config_instance', + ['command_driver_delegated_section_data'], + indirect=True) +def test_execute_skips_when_destroy_strategy_is_never(_patched_destroy_setup, + patched_logger_warn, + _patched_ansible_destroy, + config_instance): config_instance.command_args = {'destroy': 'never'} d = destroy.Destroy(config_instance) @@ -70,12 +71,13 @@ def test_execute_skips_when_destroy_strategy_is_never( assert not _patched_ansible_destroy.called -@pytest.mark.parametrize( - 'config_instance', ['command_driver_delegated_section_data'], - indirect=True) -def test_execute_skips_when_delegated_driver( - _patched_destroy_setup, patched_logger_warn, _patched_ansible_destroy, - config_instance): +@pytest.mark.parametrize('config_instance', + ['command_driver_delegated_section_data'], + indirect=True) +def test_execute_skips_when_delegated_driver(_patched_destroy_setup, + patched_logger_warn, + _patched_ansible_destroy, + config_instance): d = destroy.Destroy(config_instance) d.execute() diff --git a/test/unit/command/test_idempotence.py b/test/unit/command/test_idempotence.py index 28bc0c861b..9765a8b0d3 100644 --- a/test/unit/command/test_idempotence.py +++ b/test/unit/command/test_idempotence.py @@ -58,8 +58,9 @@ def test_execute(mocker, patched_logger_info, patched_ansible_converge, patched_logger_success.assert_called_once_with(msg) -def test_execute_raises_when_not_converged( - patched_logger_critical, patched_ansible_converge, _instance): +def test_execute_raises_when_not_converged(patched_logger_critical, + patched_ansible_converge, + _instance): _instance._config.state.change_state('converged', False) with pytest.raises(SystemExit) as e: _instance.execute() @@ -70,9 +71,10 @@ def test_execute_raises_when_not_converged( patched_logger_critical.assert_called_once_with(msg) -def test_execute_raises_when_fails_idempotence( - mocker, patched_logger_critical, patched_ansible_converge, - _patched_is_idempotent, _instance): +def test_execute_raises_when_fails_idempotence(mocker, patched_logger_critical, + patched_ansible_converge, + _patched_is_idempotent, + _instance): _patched_is_idempotent.return_value = False with pytest.raises(SystemExit) as e: _instance.execute() diff --git a/test/unit/command/test_list.py b/test/unit/command/test_list.py index 926f3574b0..1f55e9debb 100644 --- a/test/unit/command/test_list.py +++ b/test/unit/command/test_list.py @@ -25,20 +25,18 @@ def test_execute(capsys, config_instance): l = list.List(config_instance) x = [ - base.Status( - instance_name='instance-1', - driver_name='docker', - provisioner_name='ansible', - scenario_name='default', - created='false', - converged='false'), - base.Status( - instance_name='instance-2', - driver_name='docker', - provisioner_name='ansible', - scenario_name='default', - created='false', - converged='false'), + base.Status(instance_name='instance-1', + driver_name='docker', + provisioner_name='ansible', + scenario_name='default', + created='false', + converged='false'), + base.Status(instance_name='instance-2', + driver_name='docker', + provisioner_name='ansible', + scenario_name='default', + created='false', + converged='false'), ] assert x == l.execute() diff --git a/test/unit/command/test_login.py b/test/unit/command/test_login.py index 173f7ff718..7e49c5bd9b 100644 --- a/test/unit/command/test_login.py +++ b/test/unit/command/test_login.py @@ -38,9 +38,9 @@ def test_execute(mocker, _instance): m.assert_called_once_with('instance-1') -@pytest.mark.parametrize( - 'config_instance', ['command_driver_delegated_managed_section_data'], - indirect=True) +@pytest.mark.parametrize('config_instance', + ['command_driver_delegated_managed_section_data'], + indirect=True) def test_execute_raises_when_not_created(patched_logger_critical, _instance): _instance._config.state.change_state('created', False) diff --git a/test/unit/command/test_prepare.py b/test/unit/command/test_prepare.py index dfd0547400..f0e35501b7 100644 --- a/test/unit/command/test_prepare.py +++ b/test/unit/command/test_prepare.py @@ -65,8 +65,9 @@ def test_execute_skips_when_instances_already_prepared( assert not _patched_ansible_prepare.called -def test_execute_skips_when_playbook_not_configured( - patched_logger_warn, _patched_ansible_prepare, config_instance): +def test_execute_skips_when_playbook_not_configured(patched_logger_warn, + _patched_ansible_prepare, + config_instance): p = prepare.Prepare(config_instance) p.execute() diff --git a/test/unit/conftest.py b/test/unit/conftest.py index a07d589bfb..12169e4f6a 100644 --- a/test/unit/conftest.py +++ b/test/unit/conftest.py @@ -135,11 +135,12 @@ def _molecule_verifier_section_data(): @pytest.fixture -def molecule_data( - _molecule_dependency_galaxy_section_data, - _molecule_driver_section_data, _molecule_lint_section_data, - _molecule_platforms_section_data, _molecule_provisioner_section_data, - _molecule_scenario_section_data, _molecule_verifier_section_data): +def molecule_data(_molecule_dependency_galaxy_section_data, + _molecule_driver_section_data, _molecule_lint_section_data, + _molecule_platforms_section_data, + _molecule_provisioner_section_data, + _molecule_scenario_section_data, + _molecule_verifier_section_data): fixtures = [ _molecule_dependency_galaxy_section_data, diff --git a/test/unit/cookiecutter/test_molecule.py b/test/unit/cookiecutter/test_molecule.py index aa24a6acd5..f0af69084e 100644 --- a/test/unit/cookiecutter/test_molecule.py +++ b/test/unit/cookiecutter/test_molecule.py @@ -116,8 +116,9 @@ def test_drivers(driver, temp_dir, _molecule_file, _role_directory, pytest.helpers.run_command(cmd) -def test_verifier_lint_when_verifier_inspec( - temp_dir, _molecule_file, _role_directory, _command_args, _instance): +def test_verifier_lint_when_verifier_inspec(temp_dir, _molecule_file, + _role_directory, _command_args, + _instance): _command_args['verifier_name'] = 'inspec' _command_args['verifier_lint_name'] = 'rubocop' _instance._process_templates('molecule', _command_args, _role_directory) @@ -130,8 +131,9 @@ def test_verifier_lint_when_verifier_inspec( pytest.helpers.run_command(cmd) -def test_verifier_lint_when_verifier_goss( - temp_dir, _molecule_file, _role_directory, _command_args, _instance): +def test_verifier_lint_when_verifier_goss(temp_dir, _molecule_file, + _role_directory, _command_args, + _instance): _command_args['verifier_name'] = 'goss' _command_args['verifier_lint_name'] = 'yamllint' _instance._process_templates('molecule', _command_args, _role_directory) diff --git a/test/unit/dependency/test_ansible_galaxy.py b/test/unit/dependency/test_ansible_galaxy.py index da304c4e13..584fb2a27a 100644 --- a/test/unit/dependency/test_ansible_galaxy.py +++ b/test/unit/dependency/test_ansible_galaxy.py @@ -100,8 +100,8 @@ def test_enabled_property(_instance): assert _instance.enabled -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_options_property(_instance, role_file, roles_path): x = { 'force': True, @@ -114,8 +114,8 @@ def test_options_property(_instance, role_file, roles_path): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_options_property_handles_cli_args(role_file, roles_path, _instance): _instance._config.args = {'debug': True} x = { @@ -129,14 +129,14 @@ def test_options_property_handles_cli_args(role_file, roles_path, _instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_bake(_instance, role_file, roles_path): _instance.bake() x = [ @@ -164,8 +164,9 @@ def test_execute(patched_run_command, patched_logger_success.assert_called_once_with(msg) -def test_execute_does_not_execute_when_disabled( - patched_run_command, patched_logger_warn, _instance): +def test_execute_does_not_execute_when_disabled(patched_run_command, + patched_logger_warn, + _instance): _instance._config.config['dependency']['enabled'] = False _instance.execute() diff --git a/test/unit/dependency/test_gilt.py b/test/unit/dependency/test_gilt.py index 0a9f00a3bb..459e6c1154 100644 --- a/test/unit/dependency/test_gilt.py +++ b/test/unit/dependency/test_gilt.py @@ -81,8 +81,8 @@ def test_default_env_property(_instance): assert 'MOLECULE_INSTANCE_CONFIG' in _instance.default_env -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_name_property(_instance): assert 'gilt' == _instance.name @@ -91,16 +91,16 @@ def test_enabled_property(_instance): assert _instance.enabled -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_options_property(gilt_config, _instance): x = {'config': gilt_config, 'foo': 'bar'} assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_options_property_handles_cli_args(gilt_config, _instance): _instance._config.args = {'debug': True} x = {'config': gilt_config, 'foo': 'bar', 'debug': True} @@ -108,14 +108,14 @@ def test_options_property_handles_cli_args(gilt_config, _instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_bake(gilt_config, _instance): _instance.bake() x = [ @@ -137,8 +137,9 @@ def test_execute(patched_run_command, _patched_gilt_has_requirements_file, patched_logger_success.assert_called_once_with(msg) -def test_execute_does_not_execute_when_disabled( - patched_run_command, patched_logger_warn, _instance): +def test_execute_does_not_execute_when_disabled(patched_run_command, + patched_logger_warn, + _instance): _instance._config.config['dependency']['enabled'] = False _instance.execute() diff --git a/test/unit/dependency/test_shell.py b/test/unit/dependency/test_shell.py index 96f9dcc129..5731c3326f 100644 --- a/test/unit/dependency/test_shell.py +++ b/test/unit/dependency/test_shell.py @@ -67,8 +67,8 @@ def test_default_env_property(_instance): assert 'MOLECULE_INSTANCE_CONFIG' in _instance.default_env -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_name_property(_instance): assert 'shell' == _instance.name @@ -77,16 +77,16 @@ def test_enabled_property(_instance): assert _instance.enabled -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_options_property(_instance): x = {'foo': 'bar'} assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_options_property_handles_cli_args(_instance): _instance._config.args = {} x = {'foo': 'bar'} @@ -94,14 +94,14 @@ def test_options_property_handles_cli_args(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_bake(_instance): _instance.bake() @@ -126,8 +126,9 @@ def test_execute(patched_run_command, patched_logger_success, _instance): patched_logger_success.assert_called_once_with(msg) -def test_execute_does_not_execute_when_disabled( - patched_run_command, patched_logger_warn, _instance): +def test_execute_does_not_execute_when_disabled(patched_run_command, + patched_logger_warn, + _instance): _instance._config.config['dependency']['enabled'] = False _instance.execute() @@ -137,8 +138,8 @@ def test_execute_does_not_execute_when_disabled( patched_logger_warn.assert_called_once_with(msg) -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_execute_bakes(patched_run_command, _instance): _instance.execute() assert _instance._sh_command is not None @@ -146,8 +147,8 @@ def test_execute_bakes(patched_run_command, _instance): assert 1 == patched_run_command.call_count -@pytest.mark.parametrize( - 'config_instance', ['_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_dependency_section_data'], + indirect=True) def test_executes_catches_and_exits_return_code(patched_run_command, _instance): patched_run_command.side_effect = sh.ErrorReturnCode_1(sh.ls, b'', b'') diff --git a/test/unit/driver/test_delegated.py b/test/unit/driver/test_delegated.py index 6b8ee87346..705f1c9693 100644 --- a/test/unit/driver/test_delegated.py +++ b/test/unit/driver/test_delegated.py @@ -71,8 +71,8 @@ def test_name_property(_instance): assert 'delegated' == _instance.name -@pytest.mark.parametrize( - 'config_instance', ['_driver_unmanaged_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_unmanaged_section_data'], + indirect=True) def test_options_property(_instance): x = { 'ansible_connection_options': { @@ -85,8 +85,8 @@ def test_options_property(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_driver_managed_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_managed_section_data'], + indirect=True) def test_options_property_when_managed(_instance): x = { 'managed': True, @@ -95,16 +95,16 @@ def test_options_property_when_managed(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_driver_unmanaged_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_unmanaged_section_data'], + indirect=True) def test_login_cmd_template_property(_instance): x = 'docker exec -ti {instance} bash' assert x == _instance.login_cmd_template -@pytest.mark.parametrize( - 'config_instance', ['_driver_managed_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_managed_section_data'], + indirect=True) def test_login_cmd_template_property_when_managed(_instance): x = ('ssh {address} -l {user} -p {port} -i {identity_file} ' '-o UserKnownHostsFile=/dev/null ' @@ -132,14 +132,14 @@ def test_managed_property(_instance): assert _instance.managed -@pytest.mark.parametrize( - 'config_instance', ['_driver_unmanaged_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_unmanaged_section_data'], + indirect=True) def test_default_ssh_connection_options_property(_instance): assert [] == _instance.default_ssh_connection_options -@pytest.mark.parametrize( - 'config_instance', ['_driver_managed_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_managed_section_data'], + indirect=True) def test_default_ssh_connection_options_property_when_managed(_instance): x = [ '-o UserKnownHostsFile=/dev/null', @@ -152,14 +152,14 @@ def test_default_ssh_connection_options_property_when_managed(_instance): assert x == _instance.default_ssh_connection_options -@pytest.mark.parametrize( - 'config_instance', ['_driver_unmanaged_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_unmanaged_section_data'], + indirect=True) def test_login_options(_instance): assert {'instance': 'foo'} == _instance.login_options('foo') -@pytest.mark.parametrize( - 'config_instance', ['_driver_managed_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_managed_section_data'], + indirect=True) def test_login_options_when_managed(mocker, _instance): m = mocker.patch( 'molecule.driver.delegated.Delegated._get_instance_config') @@ -181,16 +181,16 @@ def test_login_options_when_managed(mocker, _instance): assert x == _instance.login_options('foo') -@pytest.mark.parametrize( - 'config_instance', ['_driver_unmanaged_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_unmanaged_section_data'], + indirect=True) def test_ansible_connection_options(_instance): x = {'ansible_connection': 'docker'} assert x == _instance.ansible_connection_options('foo') -@pytest.mark.parametrize( - 'config_instance', ['_driver_managed_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_managed_section_data'], + indirect=True) def test_ansible_connection_options_when_managed(mocker, _instance): ssh_case_data = mocker.patch( 'molecule.driver.delegated.Delegated._get_instance_config') @@ -265,8 +265,8 @@ def test_instance_config_property(_instance): assert x == _instance.instance_config -@pytest.mark.parametrize( - 'config_instance', ['_driver_unmanaged_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_unmanaged_section_data'], + indirect=True) def test_ssh_connection_options_property(_instance): assert [] == _instance.ssh_connection_options @@ -306,8 +306,9 @@ def _driver_options_managed_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_driver_options_managed_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_driver_options_managed_section_data'], + indirect=True) def test_created_unknown_when_managed_false( _driver_options_managed_section_data, _instance): assert 'unknown' == _instance._created() diff --git a/test/unit/driver/test_vagrant.py b/test/unit/driver/test_vagrant.py index eaf1ce1d70..3acaaca43e 100644 --- a/test/unit/driver/test_vagrant.py +++ b/test/unit/driver/test_vagrant.py @@ -72,16 +72,16 @@ def test_options_property(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_driver_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_section_data'], + indirect=True) def test_login_cmd_template_property(_instance): x = 'ssh {address} -l {user} -p {port} -i {identity_file} -o foo=bar' assert x == _instance.login_cmd_template -@pytest.mark.parametrize( - 'config_instance', ['_driver_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_section_data'], + indirect=True) def test_safe_files_property(_instance): x = [ os.path.join(_instance._config.scenario.ephemeral_directory, @@ -161,8 +161,8 @@ def test_login_options(mocker, _instance): assert x == _instance.login_options('foo') -@pytest.mark.parametrize( - 'config_instance', ['_driver_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_section_data'], + indirect=True) def test_ansible_connection_options(mocker, _instance): m = mocker.patch('molecule.driver.vagrant.Vagrant._get_instance_config') m.return_value = { @@ -221,8 +221,8 @@ def test_instance_config_property(_instance): assert x == _instance.instance_config -@pytest.mark.parametrize( - 'config_instance', ['_driver_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_driver_section_data'], + indirect=True) def test_ssh_connection_options_property(_instance): x = ['-o foo=bar'] diff --git a/test/unit/lint/test_yamllint.py b/test/unit/lint/test_yamllint.py index edb216b61e..acadb081f4 100644 --- a/test/unit/lint/test_yamllint.py +++ b/test/unit/lint/test_yamllint.py @@ -95,8 +95,8 @@ def test_enabled_property(_instance): assert _instance.enabled -@pytest.mark.parametrize( - 'config_instance', ['_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_lint_section_data'], + indirect=True) def test_options_property(_instance): x = { 's': True, @@ -106,8 +106,8 @@ def test_options_property(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_lint_section_data'], + indirect=True) def test_options_property_handles_cli_args(_instance): _instance._config.args = {'debug': True} x = { @@ -120,8 +120,8 @@ def test_options_property_handles_cli_args(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_lint_section_data'], + indirect=True) def test_bake(_patched_get_files, _instance): _instance.bake() x = [ @@ -141,8 +141,8 @@ def test_execute(_patched_get_files, patched_logger_info, _instance._yamllint_command = 'patched-yamllint-command' _instance.execute() - patched_run_command.assert_called_once_with( - 'patched-yamllint-command', debug=False) + patched_run_command.assert_called_once_with('patched-yamllint-command', + debug=False) msg = 'Executing Yamllint on files found in {}/...'.format( _instance._config.project_directory) @@ -164,8 +164,8 @@ def test_execute_does_not_execute(_patched_get_files, patched_logger_warn, patched_logger_warn.assert_called_once_with(msg) -@pytest.mark.parametrize( - 'config_instance', ['_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_lint_section_data'], + indirect=True) def test_execute_bakes(_patched_get_files, patched_run_command, _instance): _instance.execute() diff --git a/test/unit/model/test_schema_v1.py b/test/unit/model/test_schema_v1.py index 2d77e63377..2f03f6e744 100644 --- a/test/unit/model/test_schema_v1.py +++ b/test/unit/model/test_schema_v1.py @@ -28,9 +28,8 @@ @pytest.fixture def _molecule_v1_file(): - return os.path.join( - os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'resources', - 'molecule_v1_vagrant.yml') + return os.path.join(os.path.dirname(__file__), os.path.pardir, + os.path.pardir, 'resources', 'molecule_v1_vagrant.yml') @pytest.fixture diff --git a/test/unit/model/v2/conftest.py b/test/unit/model/v2/conftest.py index 8492a67159..afde54d23c 100644 --- a/test/unit/model/v2/conftest.py +++ b/test/unit/model/v2/conftest.py @@ -27,9 +27,9 @@ @pytest.fixture def _molecule_file(): - return os.path.join( - os.path.dirname(__file__), os.path.pardir, os.path.pardir, - os.path.pardir, 'resources', 'molecule_docker.yml') + return os.path.join(os.path.dirname(__file__), os.path.pardir, + os.path.pardir, os.path.pardir, 'resources', + 'molecule_docker.yml') @pytest.fixture diff --git a/test/unit/model/v2/test_dependency_section.py b/test/unit/model/v2/test_dependency_section.py index fe505e5979..a89598100e 100644 --- a/test/unit/model/v2/test_dependency_section.py +++ b/test/unit/model/v2/test_dependency_section.py @@ -40,8 +40,8 @@ def _model_dependency_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_dependency_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_dependency_section_data'], + indirect=True) def test_dependency(_config): assert {} == schema_v2.validate(_config) @@ -62,8 +62,8 @@ def _model_dependency_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_dependency_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_dependency_errors_section_data'], + indirect=True) def test_dependency_has_errors(_config): x = { 'dependency': [{ @@ -107,13 +107,12 @@ def _model_dependency_allows_shell_section_data(): } -@pytest.mark.parametrize( - '_config', [ - ('_model_dependency_allows_galaxy_section_data'), - ('_model_dependency_allows_gilt_section_data'), - ('_model_dependency_allows_shell_section_data'), - ], - indirect=True) +@pytest.mark.parametrize('_config', [ + ('_model_dependency_allows_galaxy_section_data'), + ('_model_dependency_allows_gilt_section_data'), + ('_model_dependency_allows_shell_section_data'), +], + indirect=True) def test_dependency_allows_shell_name(_config): assert {} == schema_v2.validate(_config) @@ -128,8 +127,9 @@ def _model_dependency_shell_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_dependency_shell_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', + ['_model_dependency_shell_errors_section_data'], + indirect=True) def test_dependency_shell_has_errors(_config): x = {'dependency': [{'command': ['null value not allowed']}]} diff --git a/test/unit/model/v2/test_driver_section.py b/test/unit/model/v2/test_driver_section.py index e3ca1db01a..fb88b9e8b6 100644 --- a/test/unit/model/v2/test_driver_section.py +++ b/test/unit/model/v2/test_driver_section.py @@ -47,8 +47,8 @@ def _model_driver_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_driver_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_driver_section_data'], + indirect=True) def test_driver(_config): assert {} == schema_v2.validate(_config) @@ -75,8 +75,8 @@ def _model_driver_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_driver_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_driver_errors_section_data'], + indirect=True) def test_driver_has_errors(_config): x = { 'driver': [{ @@ -110,9 +110,9 @@ def _model_driver_provider_name_nullable_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_driver_provider_name_nullable_section_data'], - indirect=True) +@pytest.mark.parametrize('_config', + ['_model_driver_provider_name_nullable_section_data'], + indirect=True) def test_driver_provider_name_nullable(_config): assert {} == schema_v2.validate(_config) @@ -217,16 +217,15 @@ def _model_driver_provider_allows_libvirt_section_data(): } -@pytest.mark.parametrize( - '_config', [ - ('_model_driver_provider_allows_virtualbox_section_data'), - ('_model_driver_provider_allows_vmware_fusion_section_data'), - ('_model_driver_provider_allows_vmware_workstation_section_data'), - ('_model_driver_provider_allows_vmware_desktop_section_data'), - ('_model_driver_provider_allows_parallels_section_data'), - ('_model_driver_provider_allows_libvirt_section_data'), - ], - indirect=True) +@pytest.mark.parametrize('_config', [ + ('_model_driver_provider_allows_virtualbox_section_data'), + ('_model_driver_provider_allows_vmware_fusion_section_data'), + ('_model_driver_provider_allows_vmware_workstation_section_data'), + ('_model_driver_provider_allows_vmware_desktop_section_data'), + ('_model_driver_provider_allows_parallels_section_data'), + ('_model_driver_provider_allows_libvirt_section_data'), +], + indirect=True) def test_driver_provider_allows_name(_config): assert {} == schema_v2.validate(_config) @@ -349,19 +348,18 @@ def _model_driver_allows_vagrant_section_data(): ### -@pytest.mark.parametrize( - '_config', [ - ('_model_driver_allows_azure_section_data'), - ('_model_driver_allows_delegated_section_data'), - ('_model_driver_allows_digitalocean_section_data'), - ('_model_driver_allows_docker_section_data'), - ('_model_driver_allows_ec2_section_data'), - ('_model_driver_allows_gce_section_data'), - ('_model_driver_allows_lxc_section_data'), - ('_model_driver_allows_lxd_section_data'), - ('_model_driver_allows_openstack_section_data'), - ('_model_driver_allows_vagrant_section_data'), - ], - indirect=True) +@pytest.mark.parametrize('_config', [ + ('_model_driver_allows_azure_section_data'), + ('_model_driver_allows_delegated_section_data'), + ('_model_driver_allows_digitalocean_section_data'), + ('_model_driver_allows_docker_section_data'), + ('_model_driver_allows_ec2_section_data'), + ('_model_driver_allows_gce_section_data'), + ('_model_driver_allows_lxc_section_data'), + ('_model_driver_allows_lxd_section_data'), + ('_model_driver_allows_openstack_section_data'), + ('_model_driver_allows_vagrant_section_data'), +], + indirect=True) def test_driver_allows_name(_config): assert {} == schema_v2.validate(_config) diff --git a/test/unit/model/v2/test_lint_section.py b/test/unit/model/v2/test_lint_section.py index 02dd300cc0..2c5e1d2707 100644 --- a/test/unit/model/v2/test_lint_section.py +++ b/test/unit/model/v2/test_lint_section.py @@ -40,8 +40,8 @@ def _model_lint_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_lint_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_lint_section_data'], + indirect=True) def test_lint(_config): assert {} == schema_v2.validate(_config) @@ -61,8 +61,8 @@ def _model_lint_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_lint_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_lint_errors_section_data'], + indirect=True) def test_lint_has_errors(_config): x = { 'lint': [{ @@ -88,9 +88,9 @@ def _model_lint_allows_yamllint_section_data(): } -@pytest.mark.parametrize( - '_config', [ - ('_model_lint_allows_yamllint_section_data'), - ], indirect=True) +@pytest.mark.parametrize('_config', [ + ('_model_lint_allows_yamllint_section_data'), +], + indirect=True) def test_lint_allows_name(_config): assert {} == schema_v2.validate(_config) diff --git a/test/unit/model/v2/test_platforms_section.py b/test/unit/model/v2/test_platforms_section.py index 84c03074b3..f62a47a77b 100644 --- a/test/unit/model/v2/test_platforms_section.py +++ b/test/unit/model/v2/test_platforms_section.py @@ -109,14 +109,14 @@ def _model_platforms_docker_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_platforms_docker_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_platforms_docker_section_data'], + indirect=True) def test_platforms_docker(_config): assert {} == schema_v2.validate(_config) -@pytest.mark.parametrize( - '_config', ['_model_platforms_docker_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_platforms_docker_section_data'], + indirect=True) def test_platforms_unique_names(_config): instance_name = _config['platforms'][0]['name'] _config['platforms'] += [{ @@ -137,8 +137,8 @@ def test_platforms_unique_names(_config): assert expected_validation_errors == schema_v2.validate(_config) -@pytest.mark.parametrize( - '_config', ['_model_platforms_docker_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_platforms_docker_section_data'], + indirect=True) def test_platforms_docker_exposed_ports_coerced(_config): _config['platforms'][0]['exposed_ports'] = [9904] assert {} == schema_v2.validate(_config) @@ -204,8 +204,9 @@ def _model_platforms_docker_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_platforms_docker_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', + ['_model_platforms_docker_errors_section_data'], + indirect=True) def test_platforms_docker_has_errors(_config): x = { 'platforms': [{ @@ -310,8 +311,8 @@ def _model_platforms_vagrant_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_platforms_vagrant_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_platforms_vagrant_section_data'], + indirect=True) def test_platforms_vagrant(_config): assert {} == schema_v2.validate(_config) @@ -343,8 +344,9 @@ def _model_platforms_vagrant_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_platforms_vagrant_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', + ['_model_platforms_vagrant_errors_section_data'], + indirect=True) def test_platforms_vagrant_has_errors(_config): x = { 'platforms': [{ @@ -408,8 +410,8 @@ def _model_platforms_lxd_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_platforms_lxd_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_platforms_lxd_section_data'], + indirect=True) def test_platforms_lxd(_config): assert {} == schema_v2.validate(_config) @@ -444,8 +446,9 @@ def _model_platforms_lxd_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_platforms_lxd_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', + ['_model_platforms_lxd_errors_section_data'], + indirect=True) def test_platforms_lxd_has_errors(_config): x = { 'platforms': [{ @@ -498,8 +501,8 @@ def _model_platform_linode_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_platform_linode_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_platform_linode_section_data'], + indirect=True) def test_platforms_linode(_config): assert {} == schema_v2.validate(_config) @@ -519,8 +522,9 @@ def _model_platforms_linode_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_platforms_linode_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', + ['_model_platforms_linode_errors_section_data'], + indirect=True) def test_platforms_linode_has_errors(_config): expected_config = { 'platforms': [{ @@ -536,8 +540,8 @@ def test_platforms_linode_has_errors(_config): assert expected_config == schema_v2.validate(_config) -@pytest.mark.parametrize( - '_config', ['_model_platform_linode_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_platform_linode_section_data'], + indirect=True) @pytest.mark.parametrize('_required_field', ( 'distribution', 'plan', diff --git a/test/unit/model/v2/test_provisioner_section.py b/test/unit/model/v2/test_provisioner_section.py index c7b4cd0a7b..477b4c19ed 100644 --- a/test/unit/model/v2/test_provisioner_section.py +++ b/test/unit/model/v2/test_provisioner_section.py @@ -84,8 +84,8 @@ def _model_provisioner_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_provisioner_section_data'], + indirect=True) def test_provisioner(_config): assert {} == schema_v2.validate(_config) @@ -131,8 +131,8 @@ def _model_provisioner_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_provisioner_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_provisioner_errors_section_data'], + indirect=True) def test_provisioner_has_errors(_config): x = { 'provisioner': [{ @@ -235,9 +235,9 @@ def _model_provisioner_env_disallowed_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_provisioner_env_disallowed_section_data'], - indirect=True) +@pytest.mark.parametrize('_config', + ['_model_provisioner_env_disallowed_section_data'], + indirect=True) def test_provisioner_config_env_disallowed_field(_config): x = { 'provisioner': [{ @@ -266,10 +266,9 @@ def _model_provisioner_allows_ansible_section_data(): } -@pytest.mark.parametrize( - '_config', [ - ('_model_provisioner_allows_ansible_section_data'), - ], - indirect=True) +@pytest.mark.parametrize('_config', [ + ('_model_provisioner_allows_ansible_section_data'), +], + indirect=True) def test_provisioner_allows_name(_config): assert {} == schema_v2.validate(_config) diff --git a/test/unit/model/v2/test_scenario_section.py b/test/unit/model/v2/test_scenario_section.py index f372da0d8f..5a7714d554 100644 --- a/test/unit/model/v2/test_scenario_section.py +++ b/test/unit/model/v2/test_scenario_section.py @@ -47,8 +47,8 @@ def _model_scenario_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_scenario_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_scenario_section_data'], + indirect=True) def test_scenario(_config): assert {} == schema_v2.validate(_config) @@ -77,8 +77,8 @@ def _model_scenario_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_scenario_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_scenario_errors_section_data'], + indirect=True) def test_scenario_has_errors(_config): x = { 'scenario': [{ diff --git a/test/unit/model/v2/test_verifier_section.py b/test/unit/model/v2/test_verifier_section.py index 7fa7baf3a2..cf19729026 100644 --- a/test/unit/model/v2/test_verifier_section.py +++ b/test/unit/model/v2/test_verifier_section.py @@ -55,8 +55,8 @@ def _model_verifier_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_verifier_section_data'], + indirect=True) def test_verifier(_config): assert {} == schema_v2.validate(_config) @@ -89,8 +89,8 @@ def _model_verifier_errors_section_data(): } -@pytest.mark.parametrize( - '_config', ['_model_verifier_errors_section_data'], indirect=True) +@pytest.mark.parametrize('_config', ['_model_verifier_errors_section_data'], + indirect=True) def test_verifier_has_errors(_config): x = { 'verifier': [{ @@ -156,13 +156,12 @@ def _model_verifier_allows_goss_section_data(): } -@pytest.mark.parametrize( - '_config', [ - ('_model_verifier_allows_testinfra_section_data'), - ('_model_verifier_allows_inspec_section_data'), - ('_model_verifier_allows_goss_section_data'), - ], - indirect=True) +@pytest.mark.parametrize('_config', [ + ('_model_verifier_allows_testinfra_section_data'), + ('_model_verifier_allows_inspec_section_data'), + ('_model_verifier_allows_goss_section_data'), +], + indirect=True) def test_verifier_allows_name(_config): assert {} == schema_v2.validate(_config) @@ -197,12 +196,11 @@ def _model_verifier_errors_goss_readonly_options_section_data(): } -@pytest.mark.parametrize( - '_config', [ - ('_model_verifier_errors_inspec_readonly_options_section_data'), - ('_model_verifier_errors_goss_readonly_options_section_data'), - ], - indirect=True) +@pytest.mark.parametrize('_config', [ + ('_model_verifier_errors_inspec_readonly_options_section_data'), + ('_model_verifier_errors_goss_readonly_options_section_data'), +], + indirect=True) def test_verifier_errors_readonly_options_section_data(_config): x = {'verifier': [{'options': [{'foo': ['field is read-only']}]}]} diff --git a/test/unit/provisioner/lint/test_ansible_lint.py b/test/unit/provisioner/lint/test_ansible_lint.py index d08ba2dd29..a9492f76fe 100644 --- a/test/unit/provisioner/lint/test_ansible_lint.py +++ b/test/unit/provisioner/lint/test_ansible_lint.py @@ -82,8 +82,8 @@ def test_enabled_property(_instance): assert _instance.enabled -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_lint_section_data'], + indirect=True) def test_options_property(_instance): x = { 'default_exclude': [_instance._config.scenario.ephemeral_directory], @@ -102,8 +102,8 @@ def test_options_property(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_lint_section_data'], + indirect=True) def test_options_property_handles_cli_args(_instance): _instance._config.args = {'debug': True} x = { @@ -130,8 +130,8 @@ def test_default_env_property(_instance): assert 'MOLECULE_INSTANCE_CONFIG' in _instance.default_env -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_lint_section_data'], + indirect=True) def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] assert 'ANSIBLE_CONFIG' in _instance.env @@ -140,8 +140,8 @@ def test_env_property(_instance): assert 'ANSIBLE_FILTER_PLUGINS' in _instance.env -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_lint_section_data'], + indirect=True) def test_bake(_instance): _instance.bake() x = [ @@ -167,8 +167,8 @@ def test_execute(mocker, patched_run_command, patched_logger_info, _instance._ansible_lint_command = 'patched-ansiblelint-command' _instance.execute() - patched_run_command.assert_called_once_with( - 'patched-ansiblelint-command', debug=False) + patched_run_command.assert_called_once_with('patched-ansiblelint-command', + debug=False) msg = 'Executing Ansible Lint on {}...'.format( _instance._config.provisioner.playbooks.converge) diff --git a/test/unit/provisioner/test_ansible.py b/test/unit/provisioner/test_ansible.py index 70a77e4fd6..78f5394f77 100644 --- a/test/unit/provisioner/test_ansible.py +++ b/test/unit/provisioner/test_ansible.py @@ -171,8 +171,8 @@ def test_lint_property(_instance): assert isinstance(_instance.lint, ansible_lint.AnsibleLint) -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_config_options_property(_instance): x = { 'defaults': { @@ -192,8 +192,8 @@ def test_config_options_property(_instance): assert x == _instance.config_options -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_options_property(_instance): x = { 'become': True, @@ -228,8 +228,8 @@ def test_options_property_handles_cli_args(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_env_property(_instance): x = _instance._config.provisioner.config_file @@ -237,8 +237,8 @@ def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_env_appends_env_property(_instance): x = [ util.abs_path( @@ -277,16 +277,16 @@ def test_env_appends_env_property(_instance): assert x == _instance.env['ANSIBLE_FILTER_PLUGINS'].split(':') -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_host_vars_property(_instance): x = {'instance-1': [{'foo': 'bar'}], 'localhost': [{'foo': 'baz'}]} assert x == _instance.host_vars -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_group_vars_property(_instance): x = { 'example_group1': [{ @@ -300,8 +300,8 @@ def test_group_vars_property(_instance): assert x == _instance.group_vars -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_hosts_property(_instance): hosts = { 'all': { @@ -323,8 +323,8 @@ def test_links_property(_instance): assert {} == _instance.links -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_inventory_property(_instance): x = { 'ungrouped': { @@ -473,8 +473,8 @@ def test_inventory_property(_instance): assert x == _instance.inventory -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_inventory_property_handles_missing_groups(temp_dir, _instance): platforms = [{'name': 'instance-1'}, {'name': 'instance-2'}] _instance._config.config['platforms'] = platforms @@ -590,8 +590,8 @@ def test_playbooks_side_effect_property(_instance): assert _instance.playbooks.side_effect is None -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_connection_options(_instance): x = {'ansible_connection': 'docker', 'foo': 'bar'} @@ -727,9 +727,10 @@ def test_manage_inventory(_instance, _patched_write_inventory, assert not _patched_link_or_update_vars.called -def test_manage_inventory_with_links( - _instance, _patched_write_inventory, _patched_remove_vars, - patched_add_or_update_vars, _patched_link_or_update_vars): +def test_manage_inventory_with_links(_instance, _patched_write_inventory, + _patched_remove_vars, + patched_add_or_update_vars, + _patched_link_or_update_vars): c = _instance._config.config c['provisioner']['inventory']['links'] = {'foo': 'bar'} _instance.manage_inventory() @@ -740,8 +741,8 @@ def test_manage_inventory_with_links( _patched_link_or_update_vars.assert_called_once_with() -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_add_or_update_vars(_instance): inventory_dir = _instance._config.scenario.inventory_directory @@ -769,8 +770,8 @@ def test_add_or_update_vars(_instance): assert util.safe_load_file(hosts) == _instance.hosts -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_add_or_update_vars_without_host_vars(_instance): c = _instance._config.config c['provisioner']['inventory']['host_vars'] = {} @@ -818,8 +819,8 @@ def test_add_or_update_vars_does_not_create_vars(_instance): assert not os.path.isfile(hosts) -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_write_inventory(temp_dir, _instance): _instance._write_inventory() @@ -974,8 +975,8 @@ def test_write_inventory(temp_dir, _instance): assert x == data -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_provisioner_section_data'], + indirect=True) def test_remove_vars(_instance): inventory_dir = _instance._config.scenario.inventory_directory @@ -1068,8 +1069,9 @@ def test_verify_inventory(_instance): _instance._verify_inventory() -def test_verify_inventory_raises_when_missing_hosts( - temp_dir, patched_logger_critical, _instance): +def test_verify_inventory_raises_when_missing_hosts(temp_dir, + patched_logger_critical, + _instance): _instance._config.config['platforms'] = [] with pytest.raises(SystemExit) as e: _instance._verify_inventory() diff --git a/test/unit/provisioner/test_ansible_playbooks.py b/test/unit/provisioner/test_ansible_playbooks.py index be1a3722e3..1005a8acff 100644 --- a/test/unit/provisioner/test_ansible_playbooks.py +++ b/test/unit/provisioner/test_ansible_playbooks.py @@ -119,8 +119,9 @@ def _provisioner_driver_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_provisioner_driver_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_provisioner_driver_section_data'], + indirect=True) def test_get_ansible_playbook_with_driver_key(tmpdir, _instance): x = os.path.join(_instance._config.scenario.directory, 'docker-create.yml') util.write_file(x, '') diff --git a/test/unit/test_config.py b/test/unit/test_config.py index b015b67cf0..1fe45f9351 100644 --- a/test/unit/test_config.py +++ b/test/unit/test_config.py @@ -113,8 +113,9 @@ def _config_dependency_gilt_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_dependency_gilt_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_dependency_gilt_section_data'], + indirect=True) def test_dependency_property_is_gilt(config_instance): assert isinstance(config_instance.dependency, gilt.Gilt) @@ -129,9 +130,9 @@ def _config_dependency_shell_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_dependency_shell_section_data'], - indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_dependency_shell_section_data'], + indirect=True) def test_dependency_property_is_shell(config_instance): assert isinstance(config_instance.dependency, shell.Shell) @@ -149,8 +150,9 @@ def _config_driver_azure_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_driver_azure_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_driver_azure_section_data'], + indirect=True) def test_driver_property_is_azure(config_instance): assert isinstance(config_instance.driver, azure.Azure) @@ -167,9 +169,9 @@ def _config_driver_delegated_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_driver_delegated_section_data'], - indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_driver_delegated_section_data'], + indirect=True) def test_driver_property_is_delegated(config_instance): assert isinstance(config_instance.driver, delegated.Delegated) @@ -183,9 +185,9 @@ def _config_driver_digitalocean_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_driver_digitalocean_section_data'], - indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_driver_digitalocean_section_data'], + indirect=True) def test_driver_property_is_digitalocean(config_instance): assert isinstance(config_instance.driver, digitalocean.DigitalOcean) @@ -199,8 +201,9 @@ def _config_driver_ec2_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_driver_ec2_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_driver_ec2_section_data'], + indirect=True) def test_driver_property_is_ec2(config_instance): assert isinstance(config_instance.driver, ec2.EC2) @@ -214,8 +217,9 @@ def _config_driver_gce_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_driver_gce_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_driver_gce_section_data'], + indirect=True) def test_driver_property_is_gce(config_instance): assert isinstance(config_instance.driver, gce.GCE) @@ -229,8 +233,9 @@ def _config_driver_lxc_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_driver_lxc_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_driver_lxc_section_data'], + indirect=True) def test_driver_property_is_lxc(config_instance): assert isinstance(config_instance.driver, lxc.LXC) @@ -244,8 +249,9 @@ def _config_driver_lxd_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_driver_lxd_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_driver_lxd_section_data'], + indirect=True) def test_driver_property_is_lxd(config_instance): assert isinstance(config_instance.driver, lxd.LXD) @@ -259,9 +265,9 @@ def _config_driver_openstack_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_driver_openstack_section_data'], - indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_driver_openstack_section_data'], + indirect=True) def test_driver_property_is_openstack(config_instance): assert isinstance(config_instance.driver, openstack.Openstack) @@ -278,8 +284,9 @@ def _config_driver_vagrant_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_driver_vagrant_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_driver_vagrant_section_data'], + indirect=True) def test_driver_property_is_vagrant(config_instance): assert isinstance(config_instance.driver, vagrant.Vagrant) @@ -307,8 +314,8 @@ def test_env(config_instance): x = { 'MOLECULE_DEBUG': 'False', 'MOLECULE_FILE': config_instance.molecule_file, - 'MOLECULE_ENV_FILE': util.abs_path( - config_instance.args.get('env_file')), + 'MOLECULE_ENV_FILE': + util.abs_path(config_instance.args.get('env_file')), 'MOLECULE_INVENTORY_FILE': config_instance.provisioner.inventory_file, 'MOLECULE_EPHEMERAL_DIRECTORY': config_instance.scenario.ephemeral_directory, @@ -365,8 +372,9 @@ def _config_verifier_inspec_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_verifier_inspec_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_verifier_inspec_section_data'], + indirect=True) def test_verifier_property_is_inspec(config_instance): assert isinstance(config_instance.verifier, inspec.Inspec) @@ -383,8 +391,9 @@ def _config_verifier_goss_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_config_verifier_goss_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', + ['_config_verifier_goss_section_data'], + indirect=True) def test_verifier_property_is_goss(config_instance): assert isinstance(config_instance.verifier, goss.Goss) @@ -482,8 +491,9 @@ def test_preflight(mocker, config_instance, patched_logger_info): m.assert_called_once_with('foo', os.environ, config.MOLECULE_KEEP_STRING) -def test_preflight_exists_when_validation_fails( - mocker, patched_logger_critical, config_instance): +def test_preflight_exists_when_validation_fails(mocker, + patched_logger_critical, + config_instance): m = mocker.patch('molecule.model.schema_v2.pre_validate') m.return_value = 'validation errors' diff --git a/test/unit/test_logger.py b/test/unit/test_logger.py index 99ce840144..30b93fa117 100644 --- a/test/unit/test_logger.py +++ b/test/unit/test_logger.py @@ -67,10 +67,9 @@ def test_error(capsys): _, stderr = capsys.readouterr() - print( - '{}{}{}'.format(colorama.Fore.RED, 'foo'.rstrip(), - colorama.Style.RESET_ALL), - file=sys.stderr) + print('{}{}{}'.format(colorama.Fore.RED, 'foo'.rstrip(), + colorama.Style.RESET_ALL), + file=sys.stderr) _, x = capsys.readouterr() assert x in stderr @@ -82,10 +81,9 @@ def test_critical(capsys): _, stderr = capsys.readouterr() - print( - '{}ERROR: {}{}'.format(colorama.Fore.RED, 'foo'.rstrip(), - colorama.Style.RESET_ALL), - file=sys.stderr) + print('{}ERROR: {}{}'.format(colorama.Fore.RED, 'foo'.rstrip(), + colorama.Style.RESET_ALL), + file=sys.stderr) _, x = capsys.readouterr() assert x in stderr diff --git a/test/unit/test_migrate.py b/test/unit/test_migrate.py index 99744aa0b6..6ad8e0cbe9 100644 --- a/test/unit/test_migrate.py +++ b/test/unit/test_migrate.py @@ -28,9 +28,8 @@ @pytest.fixture def _instance(): - molecule_file = os.path.join( - os.path.dirname(__file__), os.path.pardir, 'resources', - 'molecule_v1_vagrant.yml') + molecule_file = os.path.join(os.path.dirname(__file__), os.path.pardir, + 'resources', 'molecule_v1_vagrant.yml') return migrate.Migrate(molecule_file) diff --git a/test/unit/test_util.py b/test/unit/test_util.py index cf89512f2f..3dc1117364 100644 --- a/test/unit/test_util.py +++ b/test/unit/test_util.py @@ -344,8 +344,8 @@ def test_title(): def test_abs_path(temp_dir): - x = os.path.abspath( - os.path.join(os.getcwd(), os.path.pardir, 'foo', 'bar')) + x = os.path.abspath(os.path.join(os.getcwd(), os.path.pardir, 'foo', + 'bar')) assert x == util.abs_path(os.path.join(os.path.pardir, 'foo', 'bar')) diff --git a/test/unit/verifier/lint/test_flake8.py b/test/unit/verifier/lint/test_flake8.py index 0e6eac155d..e8bef34b9c 100644 --- a/test/unit/verifier/lint/test_flake8.py +++ b/test/unit/verifier/lint/test_flake8.py @@ -74,14 +74,14 @@ def test_default_env_property(_instance): assert 'MOLECULE_INSTANCE_CONFIG' in _instance.default_env -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_name_property(_instance): assert 'flake8' == _instance.name @@ -90,8 +90,8 @@ def test_enabled_property(_instance): assert _instance.enabled -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_options_property(_instance): x = { 'foo': 'bar', @@ -100,8 +100,8 @@ def test_options_property(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_options_property_handles_cli_args(_instance): _instance._config.args = {'debug': True} x = { @@ -113,8 +113,8 @@ def test_options_property_handles_cli_args(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_bake(_instance): _instance._tests = ['test1', 'test2', 'test3'] _instance.bake() @@ -160,8 +160,8 @@ def test_does_not_execute_without_tests(patched_run_command, patched_logger_warn.assert_called_once_with(msg) -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_execute_bakes(patched_run_command, _instance): _instance._tests = ['test1', 'test2', 'test3'] _instance.execute() diff --git a/test/unit/verifier/lint/test_rubocop.py b/test/unit/verifier/lint/test_rubocop.py index 0461b559fd..3641e7cbaf 100644 --- a/test/unit/verifier/lint/test_rubocop.py +++ b/test/unit/verifier/lint/test_rubocop.py @@ -76,14 +76,14 @@ def test_default_env_property(_instance): assert 'MOLECULE_INSTANCE_CONFIG' in _instance.default_env -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_name_property(_instance): assert 'rubocop' == _instance.name @@ -92,8 +92,8 @@ def test_enabled_property(_instance): assert _instance.enabled -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_options_property(_instance): x = { 'foo': 'bar', @@ -102,8 +102,8 @@ def test_options_property(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_options_property_handles_cli_args(_instance): _instance._config.args = {'debug': True} x = { @@ -113,8 +113,8 @@ def test_options_property_handles_cli_args(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_bake(_instance): _instance._tests = ['test1', 'test2', 'test3'] _instance.bake() @@ -160,8 +160,8 @@ def test_does_not_execute_without_tests(patched_run_command, patched_logger_warn.assert_called_once_with(msg) -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_execute_bakes(patched_run_command, _instance): _instance._tests = ['test1', 'test2', 'test3'] _instance.execute() diff --git a/test/unit/verifier/lint/test_yamllint.py b/test/unit/verifier/lint/test_yamllint.py index d785d397a4..48306beed1 100644 --- a/test/unit/verifier/lint/test_yamllint.py +++ b/test/unit/verifier/lint/test_yamllint.py @@ -78,14 +78,14 @@ def test_default_env_property(_instance): assert 'MOLECULE_INSTANCE_CONFIG' in _instance.default_env -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_name_property(_instance): assert 'yamllint' == _instance.name @@ -94,8 +94,8 @@ def test_enabled_property(_instance): assert _instance.enabled -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_options_property(_instance): x = { 's': True, @@ -105,8 +105,8 @@ def test_options_property(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_options_property_handles_cli_args(_instance): _instance._config.args = {'debug': True} x = { @@ -117,8 +117,8 @@ def test_options_property_handles_cli_args(_instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_bake(_instance): _instance._tests = ['test1', 'test2', 'test3'] _instance.bake() @@ -172,8 +172,8 @@ def test_does_not_execute_without_tests(patched_run_command, patched_logger_warn.assert_called_once_with(msg) -@pytest.mark.parametrize( - 'config_instance', ['_verifier_lint_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_lint_section_data'], + indirect=True) def test_execute_bakes(patched_run_command, _instance): _instance._tests = ['test1', 'test2', 'test3'] _instance.execute() diff --git a/test/unit/verifier/test_goss.py b/test/unit/verifier/test_goss.py index ede63ad368..fcfb698e0b 100644 --- a/test/unit/verifier/test_goss.py +++ b/test/unit/verifier/test_goss.py @@ -85,14 +85,14 @@ def test_default_env_property(_instance): assert 'MOLECULE_INSTANCE_CONFIG' in _instance.default_env -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_lint_property(_instance): assert isinstance(_instance.lint, yamllint.Yamllint) @@ -111,16 +111,16 @@ def test_directory_property(_instance): assert 'tests' == parts[-1] -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_options_property(_instance): x = {} assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_options_property_handles_cli_args(_instance): _instance._config.args = {'debug': True} x = {} diff --git a/test/unit/verifier/test_inspec.py b/test/unit/verifier/test_inspec.py index 8898a1eba1..e14735cbd1 100644 --- a/test/unit/verifier/test_inspec.py +++ b/test/unit/verifier/test_inspec.py @@ -85,14 +85,14 @@ def test_default_env_property(_instance): assert 'MOLECULE_INSTANCE_CONFIG' in _instance.default_env -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_lint_property(_instance): assert isinstance(_instance.lint, rubocop.RuboCop) @@ -111,16 +111,16 @@ def test_directory_property(_instance): assert 'tests' == parts[-1] -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_options_property(_instance): x = {} assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_options_property_handles_cli_args(_instance): _instance._config.args = {'debug': True} x = {} diff --git a/test/unit/verifier/test_testinfra.py b/test/unit/verifier/test_testinfra.py index 20491a2462..2faccd2d6c 100644 --- a/test/unit/verifier/test_testinfra.py +++ b/test/unit/verifier/test_testinfra.py @@ -127,8 +127,8 @@ def test_default_env_property(_instance): assert 'MOLECULE_INSTANCE_CONFIG' in _instance.default_env -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_additional_files_or_dirs_property(_instance): tests_directory = _instance._config.verifier.directory file1_file = os.path.join(tests_directory, 'file1.py') @@ -159,8 +159,8 @@ def test_additional_files_or_dirs_property(_instance): assert sorted(x) == sorted(_instance.additional_files_or_dirs) -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_env_property(_instance): assert 'bar' == _instance.env['FOO'] assert 'ANSIBLE_CONFIG' in _instance.env @@ -197,15 +197,15 @@ def _verifier_testinfra_directory_section_data(): } -@pytest.mark.parametrize( - 'config_instance', ['_verifier_testinfra_directory_section_data'], - indirect=True) +@pytest.mark.parametrize('config_instance', + ['_verifier_testinfra_directory_section_data'], + indirect=True) def test_directory_property_overriden(_instance): assert '/tmp/foo/bar' == _instance.directory -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_options_property(inventory_file, _instance): x = { 'connection': 'ansible', @@ -219,8 +219,8 @@ def test_options_property(inventory_file, _instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_options_property_handles_cli_args(inventory_file, _instance): _instance._config.args = {'debug': True} x = { @@ -236,8 +236,8 @@ def test_options_property_handles_cli_args(inventory_file, _instance): assert x == _instance.options -@pytest.mark.parametrize( - 'config_instance', ['_verifier_section_data'], indirect=True) +@pytest.mark.parametrize('config_instance', ['_verifier_section_data'], + indirect=True) def test_bake(_patched_testinfra_get_tests, inventory_file, _instance): tests_directory = _instance._config.verifier.directory file1_file = os.path.join(tests_directory, 'file1.py') @@ -309,8 +309,9 @@ def test_execute_bakes(patched_run_command, _patched_testinfra_get_tests, assert 1 == patched_run_command.call_count -def test_executes_catches_and_exits_return_code( - patched_run_command, _patched_testinfra_get_tests, _instance): +def test_executes_catches_and_exits_return_code(patched_run_command, + _patched_testinfra_get_tests, + _instance): patched_run_command.side_effect = sh.ErrorReturnCode_1( sh.testinfra, b'', b'') with pytest.raises(SystemExit) as e: