test(python-flask, python-aiohttp, python-blueplanet): make the Connexion codegen unit tests independent of python3
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
testJsonContentHeaderParamsGeneratedTestsCompileis removed. Its only check waspython3 -m py_compileon the generatedtest_default_controller.py, which needs the optional toolchain.testInfoTitleEmbeddedAsPythonStringLiteralis re-enabled with Java-only assertions. Thesetup()kwargs checks are tightened to whole-lineassertFileContainsTrimmedLinepins of the rendered literals (description=,keywords=[...],author_email=, plus the two lineslong_description="""\and"""that bracket the docstring literal) in all four Connexion variants (python-flask, python-flaskuseConnexion3=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) andassertSetupPyValuesMatchSpec(evaluatedsetup()kwargs viaastagainst 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_compileon the generatedtest_default_controller.pyandastevaluation ofsetup()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 officialpython-flask,python-flask-connexion3andpython-blueplanetconfigs also compiles — 11/11test_*_controller.py(17/17test_*.pyincluding themodels/test_*.pymodel classes). - Java: #25563 (merged) adds
testGeneratedTestsStatementIndentWithAndWithoutCookieParamsto this same test class — an indentation check on the generated tests — so part of whatpy_compileguarded (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 +
astchecks 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 | |
|---|---|---|
AbstractPythonConnexionServerCodegenTest | 25 run, 0 failures (2 disabled) | 26 run, 0 failures |
PythonFlaskConnexionServerCodegenTest | 22 run, 0 failures | 22 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 statusshows 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 ranpython3 -m py_compileon a generated test file. - Re-enables
testInfoTitleEmbeddedAsPythonStringLiteralwith whole-line assertions on the generatedsetup.pyliterals across all four Connexion variants, replacing the previous evaluation ofsetup()kwargs via Python'sast. - Removes the
assertPythonSyntaxValidandassertSetupPyValuesMatchSpechelpers.