How to use path_select_files method in Behave

Best Python code snippet using behave

behave.junit_filter.py

Source:behave.junit_filter.py Github

copy

Full Screen

...24 reparsed = minidom.parseString(text)25 return reparsed.toprettyxml(indent=" ")26def xml_select_testcases_with_status(tree, status):27 return tree.findall(".//testcase[@status='%s']" % status)28def path_select_files(paths, pattern="*.xml"):29 if not paths:30 paths = [REPORT_DIR]31 selected = []32 for pathname in paths:33 if os.path.isdir(pathname):34 for root, dirs, files in os.walk(pathname):35 for filename in files:36 if fnmatch(filename, pattern):37 filename2 = os.path.join(root, filename)38 selected.append(os.path.normpath(filename2))39 elif os.path.isfile(pathname) and fnmatch(pathname, pattern):40 selected.append(pathname)41 return selected42def report_testcases(filename, testcases):43 print(u"REPORT: {0}".format(filename))44 for xml_testcase in testcases:45 print(" TESTCASE: {0}".format(xml_testcase.get("name")))46 xml_text = indent(xml_prettify(xml_testcase), " ")47 print(xml_text)48def main(args=None):49 """Filter JUnit XML reports to show only a subset of all information."""50 if args is None:51 args = sys.argv[1:]52 parser = argparse.ArgumentParser(prog=NAME,53 description=main.__doc__)54 parser.add_argument("-s", "--status", default="failed", required=False,55 choices=["passed", "failed", "skipped"],56 help="Status to select (passed, failed, skipped).")57 parser.add_argument("xml_file", nargs="*",58 help="XML file(s) or directory with XML files.")59 parser.add_argument("--version", action="version", version=VERSION)60 options = parser.parse_args(args)61 xml_files = options.xml_file62 xml_reports = path_select_files(xml_files)63 for xml_filename in xml_reports:64 tree = ET.parse(xml_filename)65 testcases = xml_select_testcases_with_status(tree, options.status)66 if testcases:67 report_testcases(xml_filename, testcases)68 return 069if __name__ == "__main__":...

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