if True:
sys.path.insert(0, ".")
+ from tools.toxnox import move_junit_file
from tools.toxnox import tox_parameters
from tools.toxnox import extract_opts
posargs, opts = extract_opts(session.posargs, "generate-junit")
- # produce individual junit files that are per-database (or as close as we
- # can get). jenkins junit plugin will merge all the files...
- if len(databases) == 1:
- junitfile = f"junit-{databases[0]}.xml"
- suite_name = f"pytest-{databases[0]}"
- else:
- junitfile = "junit-general.xml"
- suite_name = "pytest-general"
-
if opts.generate_junit:
- cmd.extend(["--junitxml", junitfile])
+ cmd.extend(["--junitxml", "junit-tmp.xml"])
cmd.extend(posargs)
# get merged we can view each suite distinctly rather than them getting
# overwritten with each other since they are running the same tests
if opts.generate_junit:
- import junitparser
- xml = junitparser.JUnitXml.fromfile(junitfile)
- for suite in xml:
- suite.name = suite_name
- xml.write(junitfile)
+ # produce individual junit files that are per-database (or as close as
+ # we can get). jenkins junit plugin will merge all the files...
+ if len(databases) == 1:
+ junitfile = f"junit-{databases[0]}.xml"
+ suite_name = f"pytest-{databases[0]}"
+ else:
+ junitfile = "junit-general.xml"
+ suite_name = "pytest-general"
+
+ move_junit_file("junit-tmp.xml", junitfile, suite_name)
# Run cleanup for oracle/mssql
for database in databases:
from __future__ import annotations
import collections
+import os
import re
import sys
from typing import Any
return [arg for arg in posargs if not extract(arg)], return_tuple(
*return_args
)
+
+
+def move_junit_file(tmpfilename: str, newname: str, suite_name: str):
+ import junitparser
+
+ xml = junitparser.JUnitXml.fromfile(tmpfilename)
+ for suite in xml:
+ suite.name = suite_name
+ xml.write(newname)
+ os.unlink(tmpfilename)