def load_step_definitions(self, extra_step_paths=None): if extra_step_paths is None: extra_step_paths = [] # -- Allow steps to import other stuff from the steps dir # NOTE: Default matcher can be overridden in "environment.py" hook. steps_dir = os.path.join(self.base_dir, self.config.steps_dir) step_paths = [steps_dir] + list(extra_step_paths) load_step_modules(step_paths)
def get_step_definition(feature, input): parsed_input = " ".join(input.lstrip().split(" ")[1:]).lstrip() base_path = os.path.dirname(os.path.abspath(feature)) steps_paths = [os.path.join(base_path, "steps")] runner_util.exec_file(os.path.join(base_path, "environment.py")) runner_util.load_step_modules(steps_paths) for step_type in registry.steps.keys(): steps = list(registry.steps[step_type]) if not steps: continue for step in registry.steps[step_type]: if step.match(parsed_input): file = step.location.abspath() line = step.location.line print(f"edit +{line} {file}") exit(0) return print("echo 'Not found'") exit(1)
from behave.runner_util import load_step_modules import sys import os # site_packages = next(p for p in sys.path if (p.endswith('site-packages') and p.startswith('/Library'))) # SUBSTEP_DIRS = [os.path.join(site_packages, 'infostretch/automation/step_def')] load_step_modules(['infostretch/automation/step_def'])