How to use write_molecule_file method in molecule

Best Python code snippet using molecule_python

conftest.py

Source:conftest.py Github

copy

Full Screen

...9 from pathlib import Path10except ImportError:11 from pathlib2 import Path12@pytest.helpers.register13def write_molecule_file(filename, data):14 util.write_file(filename, util.safe_dump(data))15@pytest.helpers.register16def os_split(s):17 rest, tail = os.path.split(s)18 if rest in ("", os.path.sep):19 return (tail,)20 return os_split(rest) + (tail,)21@pytest.fixture22def _molecule_dependency_galaxy_section_data():23 return {"dependency": {"name": "galaxy"}}24@pytest.fixture25def _molecule_driver_section_data():26 return {"driver": {"name": "hetznercloud", "options": {"managed": True}}}27@pytest.fixture28def _molecule_platforms_section_data():29 return {30 "platforms": [31 {"name": "instance-1", "groups": ["foo", "bar"], "children": ["child1"]},32 {"name": "instance-2", "groups": ["baz", "foo"], "children": ["child2"]},33 ]34 }35@pytest.fixture36def _molecule_provisioner_section_data():37 return {38 "provisioner": {39 "name": "ansible",40 "options": {"become": True},41 "lint": {"name": "ansible-lint"},42 "config_options": {},43 }44 }45@pytest.fixture46def _molecule_scenario_section_data():47 return {"scenario": {"name": "default"}}48@pytest.fixture49def _molecule_verifier_section_data():50 return {"verifier": {"name": "testinfra", "lint": {"name": "flake8"}}}51@pytest.fixture52def molecule_data(53 _molecule_dependency_galaxy_section_data,54 _molecule_driver_section_data,55 _molecule_platforms_section_data,56 _molecule_provisioner_section_data,57 _molecule_scenario_section_data,58 _molecule_verifier_section_data,59):60 fixtures = [61 _molecule_dependency_galaxy_section_data,62 _molecule_driver_section_data,63 _molecule_platforms_section_data,64 _molecule_provisioner_section_data,65 _molecule_scenario_section_data,66 _molecule_verifier_section_data,67 ]68 return functools.reduce(lambda x, y: util.merge_dicts(x, y), fixtures)69@pytest.fixture70def molecule_directory_fixture(temp_dir):71 return pytest.helpers.molecule_directory()72@pytest.fixture73def molecule_scenario_directory_fixture(molecule_directory_fixture):74 path = pytest.helpers.molecule_scenario_directory()75 if not os.path.isdir(path):76 os.makedirs(path)77 return path78@pytest.fixture79def molecule_ephemeral_directory_fixture(molecule_scenario_directory_fixture):80 path = pytest.helpers.molecule_ephemeral_directory(str(uuid4()))81 if not os.path.isdir(path):82 os.makedirs(path)83 yield84 shutil.rmtree(str(Path(path).parent))85@pytest.fixture86def molecule_file_fixture(87 molecule_scenario_directory_fixture, molecule_ephemeral_directory_fixture88):89 return pytest.helpers.molecule_file()90@pytest.fixture91def config_instance(molecule_file_fixture, molecule_data, request):92 mdc = copy.deepcopy(molecule_data)93 if hasattr(request, "param"):94 util.merge_dicts(mdc, request.getfixturevalue(request.param))95 pytest.helpers.write_molecule_file(molecule_file_fixture, mdc)96 c = config.Config(molecule_file_fixture)97 c.command_args = {"subcommand": "test"}98 return c99# Mocks100@pytest.fixture101def patched_print_debug(mocker):102 return mocker.patch("molecule.util.print_debug")103@pytest.fixture104def patched_logger_info(mocker):105 return mocker.patch("logging.Logger.info")106@pytest.fixture107def patched_logger_out(mocker):108 return mocker.patch("molecule.logger.CustomLogger.out")109@pytest.fixture...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful