From: Mike Bayer Date: Mon, 6 Oct 2025 20:01:03 +0000 (-0400) Subject: test updates X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;p=thirdparty%2Fsqlalchemy%2Falembic.git test updates * remove .coveragerc since this produces warnings vs. pytest-cov * use junitparser to rename the suite inside each junit file. I think jenkins junit reads multiple files but they need to have distinct suite names to show up (or distinct test names, but we dont have that here). Change-Id: Ic785969e7b41408eeb50028339c27c7e459cd8e0 --- diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 1b33a566..00000000 --- a/.coveragerc +++ /dev/null @@ -1,5 +0,0 @@ -[run] -include=alembic/* - -[report] -omit=alembic/testing/* \ No newline at end of file diff --git a/noxfile.py b/noxfile.py index 0403a805..1be66de9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -147,7 +147,7 @@ def _tests( *nox.project.dependency_groups(pyproject, "tests_mysql") ) cmd.extend(os.environ.get("TOX_MYSQL", "--db mysql").split()) - elif databases == "oracle": + elif database == "oracle": # we'd like to use oracledb but SQLAlchemy 1.4 does not have # oracledb support... session.install( @@ -159,7 +159,6 @@ def _tests( session.env["NLS_LANG"] = os.environ.get("NLS_LANG") cmd.extend(os.environ.get("TOX_ORACLE", "--db oracle").split()) cmd.extend("--write-idents db_idents.txt".split()) - elif database == "mssql": session.install( *nox.project.dependency_groups(pyproject, "tests_mssql") @@ -168,16 +167,34 @@ def _tests( cmd.extend("--write-idents db_idents.txt".split()) 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: - if len(databases) == 1: - cmd.extend(["--junitxml", f"junit-{databases[0]}.xml"]) - else: - cmd.extend(["--junitxml", "junit-general.xml"]) + cmd.extend(["--junitxml", junitfile]) cmd.extend(posargs) session.run(*cmd) + # name the suites distinctly as well. this is so that when they + # 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) + # Run cleanup for oracle/mssql for database in databases: if database in ["oracle", "mssql"]: diff --git a/pyproject.toml b/pyproject.toml index 1b0d5879..a05d5aee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,8 @@ tests = [ "pytest>8,<8.4", "pytest-xdist", "black==25.1.0", # for test_post_write.py - "tzdata" + "tzdata", + "junitparser" ] coverage = [