How to use setup_api_with_step_decorators method in Behave

Best Python code snippet using behave

_stepimport.py

Source: _stepimport.py Github

copy

Full Screen

...17import six18# -----------------------------------------------------------------------------19# UTILITY FUNCTIONS:20# -----------------------------------------------------------------------------21def setup_api_with_step_decorators(module, step_registry):22 _step_registry.setup_step_decorators(module, step_registry)23def setup_api_with_matcher_functions(module, matcher_factory):24 module.use_step_matcher = matcher_factory.use_step_matcher25 module.step_matcher = matcher_factory.use_step_matcher26 module.register_type = matcher_factory.register_type27# -----------------------------------------------------------------------------28# FAKE MODULE CLASSES: For step imports29# -----------------------------------------------------------------------------30# class FakeModule(object):31class FakeModule(ModuleType):32 ensure_fake = True33 # -- SUPPORT FOR: behave.step_registry.setup_step_decorators()34 def __setitem__(self, name, value):35 assert "." not in name36 setattr(self, name, value)37class StepRegistryModule(FakeModule):38 """Provides a fake :mod:`behave.step_registry` module39 that can be used during step imports.40 """41 __all__ = [42 "given", "when", "then", "step",43 "Given", "When", "Then", "Step",44 ]45 def __init__(self, step_registry):46 super(StepRegistryModule, self).__init__("behave.step_registry")47 self.registry = step_registry48 setup_api_with_step_decorators(self, step_registry)49class StepMatchersModule(FakeModule):50 __all__ = ["use_step_matcher", "register_type", "step_matcher"]51 def __init__(self, matcher_factory):52 super(StepMatchersModule, self).__init__("behave.matchers")53 self.matcher_factory = matcher_factory54 setup_api_with_matcher_functions(self, matcher_factory)55 self.use_default_step_matcher = matcher_factory.use_default_step_matcher56 self.get_matcher = matcher_factory.make_matcher57 # self.matcher_mapping = matcher_mapping or _matchers.matcher_mapping.copy()58 # self.current_matcher = current_matcher or _matchers.current_matcher59 # -- INJECT PYTHON PACKAGE META-DATA:60 # REQUIRED-FOR: Non-fake submodule imports (__path__).61 here = os.path.dirname(__file__)62 self.__file__ = os.path.abspath(os.path.join(here, "matchers.py"))63 self.__name__ = "behave.matchers"64 # self.__path__ = [os.path.abspath(here)]65 # def use_step_matcher(self, name):66 # self.matcher_factory.use_step_matcher(name)67 # # self.current_matcher = self.matcher_mapping[name]68 #69 # def use_default_step_matcher(self, name=None):70 # self.matcher_factory.use_default_step_matcher(name=None)71 #72 # def get_matcher(self, func, pattern):73 # # return self.current_matcher74 # return self.matcher_factory.make_matcher(func, pattern)75 #76 # def register_type(self, **kwargs):77 # # _matchers.register_type(**kwargs)78 # self.matcher_factory.register_type(**kwargs)79 #80 # step_matcher = use_step_matcher81class BehaveModule(FakeModule):82 __all__ = StepRegistryModule.__all__ + StepMatchersModule.__all__83 def __init__(self, step_registry, matcher_factory=None):84 if matcher_factory is None:85 matcher_factory = step_registry.step_matcher_factory86 assert matcher_factory is not None87 super(BehaveModule, self).__init__("behave")88 setup_api_with_step_decorators(self, step_registry)89 setup_api_with_matcher_functions(self, matcher_factory)90 self.use_default_step_matcher = matcher_factory.use_default_step_matcher91 assert step_registry.matcher_factory == matcher_factory92 # -- INJECT PYTHON PACKAGE META-DATA:93 # REQUIRED-FOR: Non-fake submodule imports (__path__).94 here = os.path.dirname(__file__)95 self.__file__ = os.path.abspath(os.path.join(here, "__init__.py"))96 self.__name__ = "behave"97 self.__path__ = [os.path.abspath(here)]98 self.__package__ = None99class StepImportModuleContext(object):100 def __init__(self, step_container):101 self.step_registry = step_container.step_registry102 self.matcher_factory = step_container.matcher_factory...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Perform Automation Testing With Cucumber And Nightwatch JS?

This article is a part of our Content Hub. For more in-depth resources, check out our content hub on Selenium Cucumber Tutorial.

How To Use JavaScriptExecutor in Selenium WebDriver?

This article is a part of our Content Hub. For more in-depth resources, check out our content hub on Selenium JavaScript Tutorial.

E2E Headless Browser Testing Using Nightwatch JS

Headless browsers are gaining popularity as a viable option for testing web applications. As we all know, web browsers are an integral part of automation testing using Selenium Webdriver. While performing Selenium automation testing, Selenium launches the corresponding browser defined in the script during the test run and then executes test steps. However, issues like the slow rendering of web pages can be a potential issue that can delay the test execution speed. As a solution, headless browser testing was introduced to speed up test execution time.

Cypress vs Selenium – Which Is Better ?

Selenium is one of the most prominent automation frameworks for functional testing and web app testing. Automation testers who use Selenium can run tests across different browser and platform combinations by leveraging an online Selenium Grid, you can learn more about what Is Selenium? Though Selenium is the go-to framework for test automation, Cypress – a relatively late entrant in the test automation game has been catching up at a breakneck pace.

Cross Browser Compatibility in WordPress Websites

WordPress is like a lighthouse, that lightens up 30% of the internet. Pivotal reason behind it’s huge success is the level of customization that it offers along with huge amount of community support in the form of plugins, themes, extensions, etc. .

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