Commit bacf4119 authored by James R. Wilcox's avatar James R. Wilcox
Browse files

add --index option

parent 7a2e7d02
......@@ -79,13 +79,14 @@ specific_file_tests = {}
add option to run all tests by running script w/ argval 'all',
and add option to run individual test files by name (removing '-exercise-' infix substring if present)
'''
for tests in CURRENT_TESTS.values():
for chapterkey, tests in CURRENT_TESTS.items():
all_tests.extend(tests)
for test in tests:
for i, test in enumerate(tests):
arg_val = re.sub(r'-exercise', '', test)
arg_val = re.sub(r'-tests.md', '', arg_val)
specific_file_tests[arg_val] = [test]
specific_file_tests[chapterkey + '-' + str(i + 1)] = [test]
CURRENT_TESTS["all"] = all_tests
......@@ -200,13 +201,23 @@ def parse_arguments(argv):
default="chapter2",
choices=list(CURRENT_TESTS),
help="Which chapter's tests to run")
parser.add_argument("--index",
type=int,
help="Run the nth test from the chapter. "
"(Requires passing a full chapter name.)")
args = parser.parse_args(argv[1:])
return args
def main(argv):
args = parse_arguments(argv)
tests = CURRENT_TESTS[args.chapter]
testkey = args.chapter
if args.index is not None:
assert args.chapter.startswith("chapter")
testkey = args.chapter + "-" + str(args.index)
tests = CURRENT_TESTS[testkey]
mapped_results = run_doctests(tests)
total_state = "all passed"
print("\nSummarised results\n")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment