MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / apply_pytest_opts

Function apply_pytest_opts

tools/toxnox.py:210–252  ·  view source on GitHub ↗
(
    session: nox.Session,
    cov: str,
    tokens: list[str],
    *,
    coverage: bool = False,
)

Source from the content-addressed store, hash-verified

208
209
210def apply_pytest_opts(
211 session: nox.Session,
212 cov: str,
213 tokens: list[str],
214 *,
215 coverage: bool = False,
216) -> list[str]:
217 posargs, opts = extract_opts(session.posargs, "generate-junit")
218
219 if session.python and isinstance(session.python, str):
220 python_token = session.python.replace(".", "")
221 tokens.insert(0, python_token)
222
223 file_suffix = "-".join(t for t in tokens if not t.startswith("_"))
224
225 if coverage:
226
227 session.env["COVERAGE_FILE"] = coverage_file = (
228 f".coverage.{file_suffix}"
229 )
230 coverage_xml_file = f"coverage-{file_suffix}.xml"
231
232 if os.path.exists(coverage_file):
233 os.unlink(coverage_file)
234 posargs.extend(
235 [
236 f"--cov={cov}",
237 "--cov-append",
238 "--cov-report",
239 "term",
240 "--cov-report",
241 f"xml:{coverage_xml_file}",
242 ],
243 )
244 session.log(f"Will store coverage data in {coverage_file}")
245 session.log(f"Will write xml coverage data to {coverage_xml_file}")
246
247 if opts.generate_junit:
248 junitfile = f"junit-{file_suffix}.xml"
249 session.log(f"Will store junit xml in {junitfile}")
250 posargs.extend(["--junitxml", junitfile])
251
252 return posargs

Callers 2

_testsFunction · 0.90
test_mypyFunction · 0.90

Calls 9

extract_optsFunction · 0.85
unlinkMethod · 0.80
logMethod · 0.80
replaceMethod · 0.45
insertMethod · 0.45
joinMethod · 0.45
startswithMethod · 0.45
existsMethod · 0.45
extendMethod · 0.45

Tested by 1

test_mypyFunction · 0.72