test(python-flask, python-aiohttp, python-blueplanet): make the Connexion codegen unit tests independent of python3

Merged
KH
4d ago
+38-96

Follow-up to #25556 and #25563: the Connexion server codegen unit tests no longer require a python3 toolchain — #25556 disabled two tests because they need python3, and this PR resolves them for good instead of leaving them disabled.

This PR contains Java test changes only — no GitHub workflow and no helper script are included. The python3-based checks are not dropped silently; see "Coverage kept" below.

What changed

  • testJsonContentHeaderParamsGeneratedTestsCompile is removed. Its only check was python3 -m py_compile on the generated test_default_controller.py, which needs the optional toolchain.
  • testInfoTitleEmbeddedAsPythonStringLiteral is re-enabled with Java-only assertions. The setup() kwargs checks are tightened to whole-line assertFileContainsTrimmedLine pins of the rendered literals (description=, keywords=[...], author_email=, plus the two lines long_description="""\ and """ that bracket the docstring literal) in all four Connexion variants (python-flask, python-flask useConnexion3=true, python-aiohttp, python-blueplanet). Because each pin must match the whole trimmed line, a line carrying anything extra — e.g. a literal that stops short and leaves trailing content — can no longer pass.
  • The python3 helpers go away with them: assertPythonSyntaxValid (python3 -m py_compile) and assertSetupPyValuesMatchSpec (evaluated setup() kwargs via ast against the parsed spec).

Coverage kept

  • Local python3 verification (author-run, on this PR's tree — #25563 is now merged): the same two checks the removed tests performed — py_compile on the generated test_default_controller.py and ast evaluation of setup() kwargs against the spec — were run over 2 specs × 4 variants = 8/8 combinations, all OK with an author-run local script (not part of this PR). Every test module generated by the official python-flask, python-flask-connexion3 and python-blueplanet configs also compiles — 11/11 test_*_controller.py (17/17 test_*.py including the models/test_*.py model classes).
  • Java: #25563 (merged) adds testGeneratedTestsStatementIndentWithAndWithoutCookieParams to this same test class — an indentation check on the generated tests — so part of what py_compile guarded (the statement layout of the generated tests) is covered again without python3.
  • I also have a draft GitHub workflow that runs the same py_compile + ast checks on every related change (it has only been run locally, not on GitHub Actions); I can send it as a separate PR if you would like it.

Test results

./mvnw -pl modules/openapi-generator -am -Dtest=AbstractPythonConnexionServerCodegenTest,PythonFlaskConnexionServerCodegenTest test with python3 removed from PATH:

master (#25563 merged)this PR
AbstractPythonConnexionServerCodegenTest25 run, 0 failures (2 disabled)26 run, 0 failures
PythonFlaskConnexionServerCodegenTest22 run, 0 failures22 run, 0 failures

cc @cbornet @tomplus @krjakbrjak @fa0311 (Python technical committee)

PR checklist

  • Read the contribution guidelines.

  • Run the following to build the project and update samples:

    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    

    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.

    (Test-only change — no generator code is touched. Verified by rebuilding the CLI jar (./mvnw -DskipTests -pl modules/openapi-generator-cli -am package) and regenerating the three Python Connexion sample configs (python-flask, python-flask-connexion3, python-blueplanet): git status shows no diff.)

  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

🤖 Generated with Claude Code


Summary by cubic

Makes the Connexion server codegen unit tests run entirely within Java, so the test suite no longer requires a python3 toolchain on PATH.

  • Removes testJsonContentHeaderParamsGeneratedTestsCompile, which only ran python3 -m py_compile on a generated test file.
  • Re-enables testInfoTitleEmbeddedAsPythonStringLiteral with whole-line assertions on the generated setup.py literals across all four Connexion variants, replacing the previous evaluation of setup() kwargs via Python's ast.
  • Removes the assertPythonSyntaxValid and assertSetupPyValuesMatchSpec helpers.