How to use is_parallel_session method in Slash

Best Python code snippet using slash

plugin_manager.py

Source:plugin_manager.py Github

copy

Full Screen

...101 """102 plugin_name = plugin if isinstance(plugin, str) else plugin.get_name()103 return self._installed[plugin_name].is_internal104 def _is_parallel_supported(self, plugin):105 if not parallel_utils.is_parallel_session():106 return False107 plugin_parallel_mode = try_get_mark(plugin, 'parallel_mode', parallel_utils.ParallelPluginModes.ENABLED)108 if plugin_parallel_mode == parallel_utils.ParallelPluginModes.ENABLED:109 return False110 if (plugin_parallel_mode == parallel_utils.ParallelPluginModes.DISABLED) \111 or (plugin_parallel_mode == parallel_utils.ParallelPluginModes.PARENT_ONLY and parallel_utils.is_child_session()) \112 or (plugin_parallel_mode == parallel_utils.ParallelPluginModes.CHILD_ONLY and parallel_utils.is_parent_session()):113 return True114 return False115 def configure_for_parallel_mode(self):116 for plugin in self.get_installed_plugins().values():117 if self._is_parallel_supported(plugin):118 self.deactivate_later(plugin)119 def install(self, plugin, activate=False, activate_later=False, is_internal=False):...

Full Screen

Full Screen

test_plugin_parallel.py

Source:test_plugin_parallel.py Github

copy

Full Screen

...12 config_override("parallel.num_workers", 1)13 if session_state == 'child':14 config_override("parallel.worker_id", 1)15 if session_state == 'not_parallel':16 assert not parallel_utils.is_parallel_session()17 assert not parallel_utils.is_parent_session()18 assert not parallel_utils.is_child_session()19 if session_state == 'parent':20 assert parallel_utils.is_parallel_session()21 assert parallel_utils.is_parent_session()22 assert not parallel_utils.is_child_session()23 if session_state == 'child':24 assert parallel_utils.is_parallel_session()25 assert parallel_utils.is_child_session()26 assert not parallel_utils.is_parent_session()27 plugin = mark('parallel_mode', plugin_parallel_mode)(plugin)28 assert try_get_mark(plugin, 'parallel_mode') == plugin_parallel_mode29 slash.plugins.manager.install(plugin)30 slash.plugins.manager.configure_for_parallel_mode()31 is_plugin_in_deactivation_list = plugin.get_name() in slash.plugins.manager._pending_deactivation32 if plugin_parallel_mode == parallel_utils.ParallelPluginModes.ENABLED:33 assert not is_plugin_in_deactivation_list34 elif plugin_parallel_mode == parallel_utils.ParallelPluginModes.DISABLED:35 assert is_plugin_in_deactivation_list if session_state != "not_parallel" else not is_plugin_in_deactivation_list36 elif plugin_parallel_mode == parallel_utils.ParallelPluginModes.PARENT_ONLY:37 assert is_plugin_in_deactivation_list if session_state == "child" else not is_plugin_in_deactivation_list38 elif plugin_parallel_mode == parallel_utils.ParallelPluginModes.CHILD_ONLY:39 assert is_plugin_in_deactivation_list if session_state == "parent" else not is_plugin_in_deactivation_list40@pytest.mark.parametrize('is_parallel_mode', [True, False])41def test_parallel_mode_activation_causes_warning(config_override, checkpoint, is_parallel_mode):42 @slash.plugins.parallel_mode(parallel_utils.ParallelPluginModes.DISABLED)43 class Plugin(slash.plugins.PluginInterface):44 def session_start(self):45 checkpoint()46 def get_name(self):47 return type(self).__name__.lower()48 if is_parallel_mode:49 config_override("parallel.num_workers", 1)50 assert parallel_utils.is_parallel_session()51 plugin = Plugin()52 assert try_get_mark(plugin, 'parallel_mode') == parallel_utils.ParallelPluginModes.DISABLED53 with Session():54 slash.plugins.manager.install(plugin)55 slash.plugins.manager.activate(plugin)56 slash.hooks.session_start() # pylint: disable=no-member57 warning_message_expected = "Activating plugin {} though it's configuration for parallel mode doesn't fit to current session"\58 .format(plugin.get_name())59 is_warning_appeared = warning_message_expected in [warning.message for warning in slash.session.warnings]60 assert is_warning_appeared if is_parallel_mode else not is_warning_appeared...

Full Screen

Full Screen

parallel_utils.py

Source:parallel_utils.py Github

copy

Full Screen

1from ..conf import config2def is_parallel_session():3 return config.root.parallel.num_workers != 04def is_parent_session():5 return is_parallel_session() and config.root.parallel.worker_id is None6def is_child_session():7 return config.root.parallel.worker_id is not None8class ParallelPluginModes(object):9 DISABLED, ENABLED, PARENT_ONLY, CHILD_ONLY = MODES = (10 'disabled', 'enabled', 'parent-only', 'child-only'...

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