MCPcopy Index your code
hub / github.com/python/cpython / testfile

Function testfile

Lib/doctest.py:2118–2239  ·  view source on GitHub ↗

Test examples in the given file. Return (#failures, #tests). Optional keyword arg "module_relative" specifies how filenames should be interpreted: - If "module_relative" is True (the default), then "filename" specifies a module-relative path. By default, this path is

(filename, module_relative=True, name=None, package=None,
             globs=None, verbose=None, report=True, optionflags=0,
             extraglobs=None, raise_on_error=False, parser=DocTestParser(),
             encoding=None)

Source from the content-addressed store, hash-verified

2116
2117
2118def testfile(filename, module_relative=True, name=None, package=None,
2119 globs=None, verbose=None, report=True, optionflags=0,
2120 extraglobs=None, raise_on_error=False, parser=DocTestParser(),
2121 encoding=None):
2122 """
2123 Test examples in the given file. Return (#failures, #tests).
2124
2125 Optional keyword arg "module_relative" specifies how filenames
2126 should be interpreted:
2127
2128 - If "module_relative" is True (the default), then "filename"
2129 specifies a module-relative path. By default, this path is
2130 relative to the calling module's directory; but if the
2131 "package" argument is specified, then it is relative to that
2132 package. To ensure os-independence, "filename" should use
2133 "/" characters to separate path segments, and should not
2134 be an absolute path (i.e., it may not begin with "/").
2135
2136 - If "module_relative" is False, then "filename" specifies an
2137 os-specific path. The path may be absolute or relative (to
2138 the current working directory).
2139
2140 Optional keyword arg "name" gives the name of the test; by default
2141 use the file's basename.
2142
2143 Optional keyword argument "package" is a Python package or the
2144 name of a Python package whose directory should be used as the
2145 base directory for a module relative filename. If no package is
2146 specified, then the calling module's directory is used as the base
2147 directory for module relative filenames. It is an error to
2148 specify "package" if "module_relative" is False.
2149
2150 Optional keyword arg "globs" gives a dict to be used as the globals
2151 when executing examples; by default, use {}. A copy of this dict
2152 is actually used for each docstring, so that each docstring's
2153 examples start with a clean slate.
2154
2155 Optional keyword arg "extraglobs" gives a dictionary that should be
2156 merged into the globals that are used to execute examples. By
2157 default, no extra globals are used.
2158
2159 Optional keyword arg "verbose" prints lots of stuff if true, prints
2160 only failures if false; by default, it's true iff "-v" is in sys.argv.
2161
2162 Optional keyword arg "report" prints a summary at the end when true,
2163 else prints nothing at the end. In verbose mode, the summary is
2164 detailed, else very brief (in fact, empty if all tests passed).
2165
2166 Optional keyword arg "optionflags" or's together module constants,
2167 and defaults to 0. Possible values (see the docs for details):
2168
2169 DONT_ACCEPT_TRUE_FOR_1
2170 DONT_ACCEPT_BLANKLINE
2171 NORMALIZE_WHITESPACE
2172 ELLIPSIS
2173 SKIP
2174 IGNORE_EXCEPTION_DETAIL
2175 REPORT_UDIFF

Callers 1

_testFunction · 0.85

Calls 12

runMethod · 0.95
summarizeMethod · 0.95
DocTestParserClass · 0.85
_load_testfileFunction · 0.85
DebugRunnerClass · 0.85
DocTestRunnerClass · 0.85
get_doctestMethod · 0.80
TestResultsClass · 0.70
basenameMethod · 0.45
copyMethod · 0.45
updateMethod · 0.45
mergeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…