How to use make_custom_plugin method in Slash

Best Python code snippet using slash

test_hook_calling.py

Source:test_hook_calling.py Github

copy

Full Screen

...153#### Older tests below, need modernizing ####154class HookCallingTest(_TestCase):155 def setUp(self):156 super(HookCallingTest, self).setUp()157 self.plugin1 = make_custom_plugin("plugin1", self)158 self.plugin2 = make_custom_plugin("plugin2", self, hook_names=["before_session_start", "session_start", "after_session_start"])159 self.addCleanup(plugins.manager.uninstall, self.plugin1)160 self.addCleanup(plugins.manager.uninstall, self.plugin2)161 def test_hook_calling_order(self):162 # pylint: disable=no-member163 # expect:164 with self.forge.any_order():165 self.plugin1.activate()166 self.plugin2.activate()167 with self.forge.any_order():168 self.plugin1.before_session_start()169 self.plugin2.before_session_start()170 with self.forge.any_order():171 self.plugin1.session_start()172 self.plugin2.session_start()173 with self.forge.any_order():174 self.plugin1.after_session_start()175 self.plugin2.after_session_start()176 self.plugin1.session_end()177 self.plugin1.after_session_end()178 self.forge.replay()179 # get:180 plugins.manager.install(self.plugin1, activate=True)181 plugins.manager.install(self.plugin2, activate=True)182 with slash.Session() as s:183 with s.get_started_context():184 pass185def make_custom_plugin(name, test, hook_names=None):186 class CustomPlugin(PluginInterface):187 def get_name(self):188 return name189 CustomPlugin.__name__ = name190 if hook_names is None:191 with vintage.get_no_deprecations_context():192 hook_names = [hook_name for hook_name, _ in slash.hooks.get_all_hooks()]193 for hook_name in hook_names:194 setattr(CustomPlugin, hook_name, test.forge.create_wildcard_function_stub(name=hook_name))195 setattr(CustomPlugin, "activate", test.forge.create_wildcard_function_stub(name="activate"))...

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