# pyright: reportWildcardImportFromLibrary=false from behave import * # noqa: F403 from typing import Optional import subprocess import os try: from steps.common import Case except ModuleNotFoundError: from common import Case def invoke(context, args: Optional[list[str]]): case: Case = context.case if args is None: args = [] env = dict(context.env) env["PATH"] = os.environ["PATH"] # necessary for provider scripts print("Env when invoking:") print(env) case.result = subprocess.run( [context.bin, context.case.infile] + args, capture_output=True, env=env, encoding="utf-8" ) print("Return code: {code}\nStdOut: {out}\nStdErr: {err}".format( code=case.result.returncode, out=case.result.stdout, err=case.result.stderr )) @when(u'allmytoes is started without further arguments') # noqa: F405 def step_allmytoes_is_started(context): invoke(context, None) @when(u'allmytoes is started with arguments {arguments}') # noqa: F405 def step_allmytoes_is_started_with_arguments(context, arguments): invoke(context, arguments.split(" "))