git @ Cat's Eye Technologies Falderal / 641e59d
Use ArgumentParser instead of OptionParser. Chris Pressey 2 years ago
3 changed file(s) with 20 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
22
33 Version 0.13 "Merchandise Mart":
44
5 * Use `ArgumentParser` instead of `OptionParser` internally.
56 * `--substring-error` is now the default behaviour, and if this
67 option is given, it will be ignored. After a long time
78 considering the problem, we finally determined that it does
00 Falderal
11 ========
22
3 Version 0.12 "Schoenhofen Brewery"
3 Version 0.13 "Merchandise Mart"
44
55 This is the reference distribution of Falderal, a file format for literate
66 test suites. What sets Falderal apart from most other test frameworks is
11 Usage: falderal [<option>...] <filename.markdown>...
22 """
33
4 from optparse import OptionParser
4 from argparse import ArgumentParser
55 import sys
66
77 from falderal.objects import Document, FalderalSyntaxError
1616 ##### Main #####
1717
1818 def main(args):
19 parser = OptionParser()
20 parser.add_option("-b", "--substring-error",
21 action="store_true", default=False,
22 help="no effect (provided for backwards compatibility)")
23 parser.add_option("--cavalier",
24 action="store_true", default=False,
25 help="don't perform sanity linting before running tests")
26 parser.add_option("-d", "--dump",
27 action="store_true", default=False,
28 help="print out info about parsed tests, don't run them")
29 parser.add_option("-v", "--verbose",
30 action="store_true", default=False,
31 help="print out info about each test as it is run")
19 argparser = ArgumentParser()
20 argparser.add_argument('input_files', nargs='+', metavar='FILENAME', type=str,
21 help='Falderal files containing the tests to use')
22 argparser.add_argument("-b", "--substring-error",
23 action="store_true", default=False,
24 help="no effect (provided for backwards compatibility)")
25 argparser.add_argument("--cavalier",
26 action="store_true", default=False,
27 help="don't perform sanity linting before running tests")
28 argparser.add_argument("-d", "--dump",
29 action="store_true", default=False,
30 help="print out info about parsed tests, don't run them")
31 argparser.add_argument("-v", "--verbose",
32 action="store_true", default=False,
33 help="print out info about each test as it is run")
3234
33 (options, args) = parser.parse_args(args[1:])
35 options = argparser.parse_args(args[1:])
3436
3537 if not options.substring_error:
3638 if options.verbose:
4244 functionalities = {}
4345 tests = []
4446 try:
45 for filename in args:
47 for filename in options.input_files:
4648 documents.append(Document.load(filename))
4749 for document in documents:
4850 tests += document.extract_tests(functionalities)