MCPcopy Index your code
hub / github.com/RustPython/RustPython / _test

Function _test

Lib/doctest.py:2875–2917  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2873
2874
2875def _test():
2876 import argparse
2877
2878 parser = argparse.ArgumentParser(description="doctest runner", color=True)
2879 parser.add_argument('-v', '--verbose', action='store_true', default=False,
2880 help='print very verbose output for all tests')
2881 parser.add_argument('-o', '--option', action='append',
2882 choices=OPTIONFLAGS_BY_NAME.keys(), default=[],
2883 help=('specify a doctest option flag to apply'
2884 ' to the test run; may be specified more'
2885 ' than once to apply multiple options'))
2886 parser.add_argument('-f', '--fail-fast', action='store_true',
2887 help=('stop running tests after first failure (this'
2888 ' is a shorthand for -o FAIL_FAST, and is'
2889 ' in addition to any other -o options)'))
2890 parser.add_argument('file', nargs='+',
2891 help='file containing the tests to run')
2892 args = parser.parse_args()
2893 testfiles = args.file
2894 # Verbose used to be handled by the "inspect argv" magic in DocTestRunner,
2895 # but since we are using argparse we are passing it manually now.
2896 verbose = args.verbose
2897 options = 0
2898 for option in args.option:
2899 options |= OPTIONFLAGS_BY_NAME[option]
2900 if args.fail_fast:
2901 options |= FAIL_FAST
2902 for filename in testfiles:
2903 if filename.endswith(".py"):
2904 # It is a module -- insert its dir into sys.path and try to
2905 # import it. If it is part of a package, that possibly
2906 # won't work because of package imports.
2907 dirname, filename = os.path.split(filename)
2908 sys.path.insert(0, dirname)
2909 m = __import__(filename[:-3])
2910 del sys.path[0]
2911 failures, _ = testmod(m, verbose=verbose, optionflags=options)
2912 else:
2913 failures, _ = testfile(filename, module_relative=False,
2914 verbose=verbose, optionflags=options)
2915 if failures:
2916 return 1
2917 return 0
2918
2919
2920if __name__ == "__main__":

Callers 1

doctest.pyFile · 0.70

Calls 9

parse_argsMethod · 0.95
testmodFunction · 0.85
testfileFunction · 0.85
__import__Function · 0.50
add_argumentMethod · 0.45
keysMethod · 0.45
endswithMethod · 0.45
splitMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected