MCPcopy
hub / github.com/pytest-dev/pytest / pytest_cmdline_parse

Function pytest_cmdline_parse

src/_pytest/helpconfig.py:123–152  ·  src/_pytest/helpconfig.py::pytest_cmdline_parse
()

Source from the content-addressed store, hash-verified

121
122@pytest.hookimpl(wrapper=True)
123def pytest_cmdline_parse() -> Generator[None, Config, Config]:
124 config = yield
125
126 if config.option.debug:
127 class="cm"># --debug | --debug <file.log> was provided.
128 path = config.option.debug
129 debugfile = open(path, class="st">"w", encoding=class="st">"utf-8")
130 debugfile.write(
131 class="st">"versions pytest-{}, "
132 class="st">"python-{}\ninvocation_dir={}\ncwd={}\nargs={}\n\n".format(
133 pytest.__version__,
134 class="st">".".join(map(str, sys.version_info)),
135 config.invocation_params.dir,
136 os.getcwd(),
137 config.invocation_params.args,
138 )
139 )
140 config.trace.root.setwriter(debugfile.write)
141 undo_tracing = config.pluginmanager.enable_tracing()
142 sys.stderr.write(fclass="st">"writing pytest debug information to {path}\n")
143
144 def unset_tracing() -> None:
145 debugfile.close()
146 sys.stderr.write(fclass="st">"wrote pytest debug information to {debugfile.name}\n")
147 config.trace.root.setwriter(None)
148 undo_tracing()
149
150 config.add_cleanup(unset_tracing)
151
152 return config
153
154
155def show_version_verbose(config: Config) -> None:

Callers

nothing calls this directly

Calls 4

joinMethod · 0.80
add_cleanupMethod · 0.80
writeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected