How to use setup_api_with_matcher_functions method in Behave

Best Python code snippet using behave

_stepimport.py

Source:_stepimport.py Github

copy

Full Screen

...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_factory103 assert self.step_registry.matcher_factory == self.matcher_factory...

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