def run(argv): opts = util.parse_docopt(__doc__, argv, False) biobox = opts['<biobox_type>'] image = opts['<image>'] task = opts['--task'] verbose = opts['--verbose'] log = opts['--log'] if not behave.features_available(biobox): error.err_exit("unknown_command", { "command_type": "biobox type", "command": biobox }) ctn.exit_if_no_image_available(image) if verbose: results = behave.run(biobox, image, task, False) else: results = behave.run(biobox, image, task) if verbose: if log: sys.stdout = open(log, "w+") statuses = fn.thread([ behave.get_scenarios_and_statuses(results), F(map, lambda x: name_and_status(*x)), F(list) ]) longest_name = fn.thread( [statuses, F(map, fn.first), F(map, len), max]) def justify(x, y): return x.ljust(longest_name), y output = fn.thread([ statuses, F(map, lambda x: justify(*x)), F(map, F(" ".join)), fn.unique, F("\n".join) ]) print(output) if behave.is_failed(results): exit(1) elif behave.is_failed(results): if log: sys.stderr = open(log, "w+") msg = fn.thread([ behave.get_failing_scenarios(results), F(map, behave.scenario_name), F("\n".join) ]) error.err_exit('failed_verification', { 'image': image, 'error': msg, 'biobox': biobox })
def test_get_scenarios_and_status(): features = [feature(["failed", "passing"]), feature(["failed", "passing"])] expected = [["scenario name", "failed"], ["scenario name", "passing"], ["scenario name", "failed"], ["scenario name", "passing"]] assert expected == behave.get_scenarios_and_statuses(features)
def run(argv): opts = util.parse_docopt(__doc__, argv, False) biobox = opts['<biobox_type>'] image = opts['<image>'] task = opts['--task'] verbose = opts['--verbose'] log = opts['--log'] if not behave.features_available(biobox): error.err_exit("unknown_command", {"command_type" : "biobox type", "command" : biobox}) ctn.exit_if_no_image_available(image) if verbose: results = behave.run(biobox, image, task, False) else: results = behave.run(biobox, image, task) if verbose: if log: sys.stdout = open(log, "w+") statuses = fn.thread([ behave.get_scenarios_and_statuses(results), F(map, lambda x: name_and_status(*x)), F(list)]) longest_name = fn.thread([ statuses, F(map, fn.first), F(map, len), max]) def justify(x, y): return x.ljust(longest_name), y output = fn.thread([ statuses, F(map, lambda x: justify(*x)), F(map, F(" ".join)), fn.unique, F("\n".join)]) print(output) if behave.is_failed(results): exit(1) elif behave.is_failed(results): if log: sys.stderr = open(log, "w+") msg = fn.thread([ behave.get_failing_scenarios(results), F(map, behave.scenario_name), F("\n".join)]) error.err_exit('failed_verification', {'image': image, 'error': msg, 'biobox' : biobox})
def test_get_scenarios_and_status(): features = [feature(["failed", "passing"]), feature(["failed", "passing"])] expected = [["scenario name", "failed"], ["scenario name", "passing"], ["scenario name", "failed"], ["scenario name", "passing"]] nt.assert_equal(expected, behave.get_scenarios_and_statuses(features))