How to use dependency_fixture method in Slash

Best Python code snippet using slash

test_rust_plugin.py

Source:test_rust_plugin.py Github

copy

Full Screen

...27 )28class TestPluginRustPlugin:29 """Rust plugin tests."""30 def test_validate_environment(self, dependency_fixture, part_info):31 cargo = dependency_fixture("cargo")32 rustc = dependency_fixture("rustc")33 properties = RustPlugin.properties_class.unmarshal({"source": "."})34 plugin = RustPlugin(properties=properties, part_info=part_info)35 validator = plugin.validator_class(36 part_name="my-part",37 env=f"PATH={str(cargo.parent)}:{str(rustc.parent)}",38 properties=properties,39 )40 validator.validate_environment()41 @pytest.mark.parametrize(42 "dependencies",43 [44 ("cargo", ["rustc"]),45 ("rustc", ["cargo"]),46 ],47 )48 def test_validate_environment_missing_dependencies(49 self, dependencies, dependency_fixture, part_info50 ):51 """Validate that missing dependencies raise an exception.52 :param dependencies: tuple consisting of 1 missing dependency53 and a list of valid dependencies54 """55 missing_dependency_name, valid_dependency_names = dependencies56 path = "PATH="57 for valid_dependencies_name in valid_dependency_names:58 valid_dependency = dependency_fixture(valid_dependencies_name)59 path += f":{str(valid_dependency.parent)}"60 properties = RustPlugin.properties_class.unmarshal({"source": "."})61 plugin = RustPlugin(properties=properties, part_info=part_info)62 validator = plugin.validator_class(63 part_name="my-part", env=path, properties=properties64 )65 with pytest.raises(errors.PluginEnvironmentValidationError) as raised:66 validator.validate_environment()67 assert raised.value.reason == f"'{missing_dependency_name}' not found"68 @pytest.mark.parametrize(69 "dependencies",70 [71 ("cargo", ["rustc"]),72 ("rustc", ["cargo"]),73 ],74 )75 def test_validate_environment_broken_dependencies(76 self, dependencies, dependency_fixture, part_info77 ):78 """Validate that broken dependencies raise an exception.79 :param dependencies: tuple consisting of 1 broken dependency80 and a list of valid dependencies81 """82 broken_dependency_name, valid_dependency_names = dependencies83 broken_dependency = dependency_fixture(broken_dependency_name, broken=True)84 path = f"PATH={str(broken_dependency.parent)}"85 for valid_dependencies_name in valid_dependency_names:86 valid_dependency = dependency_fixture(valid_dependencies_name)87 path += f":{str(valid_dependency.parent)}"88 properties = RustPlugin.properties_class.unmarshal({"source": "."})89 plugin = RustPlugin(properties=properties, part_info=part_info)90 validator = plugin.validator_class(91 part_name="my-part", env=path, properties=properties92 )93 with pytest.raises(errors.PluginEnvironmentValidationError) as raised:94 validator.validate_environment()95 assert (96 raised.value.reason97 == f"'{broken_dependency_name}' failed with error code 33"98 )99 def test_validate_environment_part_dependencies(self, part_info):100 properties = RustPlugin.properties_class.unmarshal({"source": "."})101 plugin = RustPlugin(properties=properties, part_info=part_info)102 validator = plugin.validator_class(103 part_name="my-part", env="PATH=/foo", properties=properties104 )105 validator.validate_environment(part_dependencies=["rust-deps"])106 @pytest.mark.parametrize(107 "satisfied_dependency,error_dependency",108 [109 ("cargo", "rustc"),110 ("rustc", "cargo"),111 ],112 )113 def test_validate_environment_missing_part_dependencies(114 self,115 satisfied_dependency,116 error_dependency,117 dependency_fixture,118 new_dir,119 part_info,120 ):121 """Validate that missing part dependencies raise an exception.122 :param dependencies: tuple consisting of 1 missing part dependency123 and a list of valid part dependencies124 """125 dependency = dependency_fixture(name=satisfied_dependency)126 properties = RustPlugin.properties_class.unmarshal({"source": "."})127 plugin = RustPlugin(properties=properties, part_info=part_info)128 validator = plugin.validator_class(129 part_name="my-part",130 properties=properties,131 env=f"PATH={str(dependency.parent)}",132 )133 with pytest.raises(errors.PluginEnvironmentValidationError) as raised:134 validator.validate_environment(part_dependencies=[])135 assert raised.value.reason == (136 f"{error_dependency!r} not found and part 'my-part' "137 "does not depend on a part named 'rust-deps' that "138 "would satisfy the dependency"139 )...

Full Screen

Full Screen

test_meson_plugin.py

Source:test_meson_plugin.py Github

copy

Full Screen

...27 )28def test_validate_environment(dependency_fixture, part_info):29 properties = MesonPlugin.properties_class.unmarshal({"source": "."})30 plugin = MesonPlugin(properties=properties, part_info=part_info)31 meson = dependency_fixture("meson")32 ninja = dependency_fixture("ninja")33 validator = plugin.validator_class(34 part_name="my-part",35 env=f"PATH={str(meson.parent)}:{str(ninja.parent)}",36 properties=properties,37 )38 validator.validate_environment()39def test_validate_environment_missing_meson(dependency_fixture, part_info):40 properties = MesonPlugin.properties_class.unmarshal({"source": "."})41 plugin = MesonPlugin(properties=properties, part_info=part_info)42 ninja = dependency_fixture("ninja")43 validator = plugin.validator_class(44 part_name="my-part",45 env=f"PATH={str(ninja.parent)}",46 properties=properties,47 )48 with pytest.raises(errors.PluginEnvironmentValidationError) as raised:49 validator.validate_environment()50 assert raised.value.reason == "'meson' not found"51def test_validate_environment_missing_ninja(dependency_fixture, part_info):52 properties = MesonPlugin.properties_class.unmarshal({"source": "."})53 plugin = MesonPlugin(properties=properties, part_info=part_info)54 meson = dependency_fixture("meson")55 validator = plugin.validator_class(56 part_name="my-part",57 env=f"PATH={str(meson.parent)}",58 properties=properties,59 )60 with pytest.raises(errors.PluginEnvironmentValidationError) as raised:61 validator.validate_environment()62 assert raised.value.reason == "'ninja' not found"63def test_validate_environment_broken_meson(dependency_fixture, part_info):64 properties = MesonPlugin.properties_class.unmarshal({"source": "."})65 plugin = MesonPlugin(properties=properties, part_info=part_info)66 meson = dependency_fixture("meson", broken=True)67 ninja = dependency_fixture("ninja")68 validator = plugin.validator_class(69 part_name="my-part",70 env=f"PATH={str(ninja.parent)}:{str(meson.parent)}",71 properties=properties,72 )73 with pytest.raises(errors.PluginEnvironmentValidationError) as raised:74 validator.validate_environment()75 assert raised.value.reason == "'meson' failed with error code 33"76def test_validate_environment_broken_ninja(dependency_fixture, part_info):77 properties = MesonPlugin.properties_class.unmarshal({"source": "."})78 plugin = MesonPlugin(properties=properties, part_info=part_info)79 meson = dependency_fixture("meson")80 ninja = dependency_fixture("ninja", broken=True)81 validator = plugin.validator_class(82 part_name="my-part",83 env=f"PATH={str(meson.parent)}:{str(ninja.parent)}",84 properties=properties,85 )86 with pytest.raises(errors.PluginEnvironmentValidationError) as raised:87 validator.validate_environment()88 assert raised.value.reason == "'ninja' failed with error code 33"89def test_validate_environment_with_meson_deps_part(part_info):90 properties = MesonPlugin.properties_class.unmarshal({"source": "."})91 plugin = MesonPlugin(properties=properties, part_info=part_info)92 validator = plugin.validator_class(93 part_name="my-part", env="PATH=/foo", properties=properties94 )...

Full Screen

Full Screen

test_fixture_resolution.py

Source:test_fixture_resolution.py Github

copy

Full Screen

...42 def global_fixture_1(dependency_fixture):43 pass44 @store.add_fixture45 @slash.fixture46 def dependency_fixture():47 pass48 expected = dependency_fixture49 store.push_namespace()50 @store.add_fixture51 @slash.fixture52 def local_fixture(global_fixture_1):53 pass54 @store.add_fixture55 @slash.fixture56 def dependency_fixture(): # pylint: disable=function-redefined57 pass58 def test_something(local_fixture):59 pass60 store.resolve()61 with s.get_started_context():62 tests = make_runnable_tests(test_something)63 test = tests[0]64 resolved = store.resolve_name('local_fixture.global_fixture_1.dependency_fixture', test, namespace=test.get_fixture_namespace()).info65 assert resolved is expected.__slash_fixture__66def test_invalid_name():67 with slash.Session() as s:68 with pytest.raises(UnknownFixtures):69 s.fixture_store.resolve_name('', start_point=object())70def test_resolve_fixture_parameterization_with_scopes(suite_builder):...

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 Slash 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