Best Python code snippet using slash
plugin_manager.py
Source:plugin_manager.py
...191 plugin_name = plugin.get_name()192 if self._is_parallel_supported(plugin):193 _logger.warn("Activating plugin {} though it's configuration for parallel mode doesn't fit to current session".format(plugin.get_name()))194 plugin.activate()195 for hook, callback, kwargs in self._get_plugin_registrations(plugin):196 hook.register(callback, **kwargs)197 self._active.add(plugin_name)198 def activate_later(self, plugin):199 """200 Adds a plugin to the set of plugins pending activation. It can be remvoed from the queue with :meth:`.deactivate_later`201 .. seealso:: :meth:`.activate_pending_plugins`202 """203 self._pending_activation.add(self._get_installed_plugin(plugin).get_name())204 def deactivate_later(self, plugin):205 """206 Removes a plugin from the set of plugins pending activation.207 .. seealso:: :meth:`.activate_pending_plugins`208 """209 self._pending_deactivation.add(self._get_installed_plugin(plugin).get_name())210 def activate_pending_plugins(self):211 """212 Activates all plugins queued with :meth:`.activate_later`213 """214 while self._pending_activation:215 plugin_name = self._pending_activation.pop()216 if plugin_name not in self._pending_deactivation:217 self.activate(plugin_name)218 while self._pending_deactivation:219 plugin_name = self._pending_deactivation.pop()220 if plugin_name in self._active:221 self.deactivate(plugin_name)222 def normalize_command_line_name(self, plugin_name):223 return plugin_name.replace(' ', '-')224 def normalize_config_name(self, plugin_name):225 return plugin_name.replace(' ', '_')226 def deactivate(self, plugin):227 """228 Deactivates a plugin, unregistering all of its hook callbacks229 :param plugin: either a plugin object or a plugin name230 """231 plugin = self._get_installed_plugin(plugin)232 plugin_name = plugin.get_name()233 token = self._get_token(plugin_name)234 if plugin_name in self._active:235 gossip.get_global_group().unregister_token(token)236 self._active.discard(plugin_name)237 plugin.deactivate()238 def _configure(self, plugin):239 cfg = plugin.get_config()240 if cfg is not None:241 warn_deprecation('PluginInterface.get_config() is deprecated. '242 'Please use PluginInterface.get_default_config() instead')243 else:244 cfg = plugin.get_default_config()245 if cfg is not None:246 plugin_name = plugin.get_name()247 config_name = self.normalize_config_name(plugin_name)248 config['plugin_config'].extend({config_name: cfg})249 def _unconfigure(self, plugin):250 plugin_config = config['plugin_config']251 config_name = self.normalize_config_name(plugin.get_name())252 if config_name in plugin_config:253 plugin_config.pop(config_name)254 def _get_token(self, plugin_name):255 return "slash.plugins.{}".format(plugin_name)256 def _get_installed_plugin_instance_by_name(self, plugin_name):257 plugin_info = self._installed.get(plugin_name)258 if plugin_info is None:259 return None260 return plugin_info.plugin_instance261 def _get_installed_plugin_instance_by_type(self, plugin_class):262 for plugin in self._installed.values():263 if type(plugin.plugin_instance) is plugin_class: # pylint: disable=unidiomatic-typecheck264 return plugin.plugin_instance265 return None266 def _get_installed_plugin(self, plugin):267 if isinstance(plugin, str):268 plugin_name = plugin269 if plugin_name in self._cmd_line_to_name:270 plugin_name = self._cmd_line_to_name[plugin_name]271 plugin_instance = self._get_installed_plugin_instance_by_name(plugin_name)272 elif isinstance(plugin, type):273 plugin_instance = self._get_installed_plugin_instance_by_type(plugin)274 plugin_name = plugin_instance.get_name() if plugin_instance is not None else repr(plugin)275 else:276 plugin_instance = plugin277 plugin_name = plugin.get_name()278 if plugin_instance is None or self._get_installed_plugin_instance_by_name(plugin_name) is not plugin_instance:279 raise UnknownPlugin("Unknown plugin: {}".format(plugin_name))280 return plugin_instance281 def _get_plugin_registrations(self, plugin):282 plugin_name = plugin.get_name()283 returned = []284 unknown = []285 global_needs = try_get_mark(plugin, 'plugin_needs', [])286 global_provides = try_get_mark(plugin, 'plugin_provides', [])287 has_session_end = has_session_start = False288 register_no_op_hooks = set()289 if global_provides:290 register_no_op_hooks.update(hook.full_name for hook in gossip.get_group('slash').get_hooks())291 for method_name in dir(type(plugin)):292 if method_name in _SKIPPED_PLUGIN_METHOD_NAMES:293 continue294 method = getattr(plugin, method_name)295 if not hasattr(method, '__call__'):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!