i'm trying write test cases python program behave expects input stdin.
i invoke this:
import my_script @when('we run "{command}"') def run(context, command): args = command.split()[1:] my_script.cli(args) and myscript.cli takes args , parses them argparse, , has line says `value = raw_input("make choice"). behave tests stop , wait input. give input in steps this:
@when('we run "{command}" , enter "{text}"') def run(context, command, text): ... i suppose have mock stdin interface , make script use in test cases, i'm not sure elegant way of doing with behave is.
behave uses "behave4cmd0" self-tests (with behave). contains step definition @when('i run "{command}"'). can register command in "environment.py" , called subprocess.
"behave4cmd0" lacking feature need interact spawned subprocess (but planned future). problem can facing has little behave. plain programming or python problem. python subprocess module or pyexpect. should provide features need.
you can aruba's interactive feature see how problem can mapped step definitions.
Comments
Post a Comment