Skip to content

Disabled python tests that require python3 - #25556

Merged
wing328 merged 1 commit into
masterfrom
disable-python-compile-test
Nov 4, 2026
Merged

wing328 merged 1 commit into
masterfrom
disable-python-compile-test

Conversation

@wing328

@wing328 wing328 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

@khayashi4337 please move the tests to github workflow instead, e.g. create a new one for your tests based on https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/samples-python-fastapi-server.yaml

as unlikely every openapi generator users have python3 installed.

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.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Disables two Python codegen tests that require a python3 toolchain, so the test suite no longer fails on environments without it.

  • The tests are annotated with enabled = false and are skipped during CI runs.
  • Coverage for the underlying behavior (JSON header params and info.title embedding) is retained by the test specs themselves; only the compile-time validation is skipped.

Written for commit e1cd2fd. Summary will update on new commits.

View guided diff Turn on auto-fix

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/openapi-generator/src/test/java/org/openapitools/codegen/python/AbstractPythonConnexionServerCodegenTest.java">

<violation number="1" location="modules/openapi-generator/src/test/java/org/openapitools/codegen/python/AbstractPythonConnexionServerCodegenTest.java:1007">
P2: `assertPythonSyntaxValid` already skips when `python3` is unavailable, so this annotation disables generated-test syntax validation even on capable runners. Remove `enabled = false` to retain the check where the toolchain exists.</violation>

<violation number="2" location="modules/openapi-generator/src/test/java/org/openapitools/codegen/python/AbstractPythonConnexionServerCodegenTest.java:1124">
P2: This annotation suppresses substantial Java-only title-literal and HTML-escaping coverage along with the `python3`-dependent AST check. Keep the test enabled and isolate the AST evaluation into a separately skippable test (or replace it with Java-side parsing).</violation>
</file>

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Turn on auto-fix | Re-trigger cubic

}

@Test(description = "info.title is embedded in generated Python source as a Python string literal, not HTML-escaped")
@Test(description = "info.title is embedded in generated Python source as a Python string literal, not HTML-escaped", enabled = false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This annotation suppresses substantial Java-only title-literal and HTML-escaping coverage along with the python3-dependent AST check. Keep the test enabled and isolate the AST evaluation into a separately skippable test (or replace it with Java-side parsing).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/test/java/org/openapitools/codegen/python/AbstractPythonConnexionServerCodegenTest.java, line 1124:

<comment>This annotation suppresses substantial Java-only title-literal and HTML-escaping coverage along with the `python3`-dependent AST check. Keep the test enabled and isolate the AST evaluation into a separately skippable test (or replace it with Java-side parsing).</comment>

<file context>
@@ -1121,7 +1121,7 @@ public void testAiohttpRequirementsIncludePythonDateutil() throws IOException {
     }
 
-    @Test(description = "info.title is embedded in generated Python source as a Python string literal, not HTML-escaped")
+    @Test(description = "info.title is embedded in generated Python source as a Python string literal, not HTML-escaped", enabled = false)
     public void testInfoTitleEmbeddedAsPythonStringLiteral() throws IOException, InterruptedException {
         // spec title: Tom & Jerry <Service> 'quoted' "dquoted" \path
</file context>

}

@Test(description = "generated tests for content (application/json) header params are valid Python syntax; kept in a separate test so a missing python3 toolchain skips only this check")
@Test(description = "generated tests for content (application/json) header params are valid Python syntax; kept in a separate test so a missing python3 toolchain skips only this check", enabled = false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: assertPythonSyntaxValid already skips when python3 is unavailable, so this annotation disables generated-test syntax validation even on capable runners. Remove enabled = false to retain the check where the toolchain exists.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/test/java/org/openapitools/codegen/python/AbstractPythonConnexionServerCodegenTest.java, line 1007:

<comment>`assertPythonSyntaxValid` already skips when `python3` is unavailable, so this annotation disables generated-test syntax validation even on capable runners. Remove `enabled = false` to retain the check where the toolchain exists.</comment>

<file context>
@@ -1004,7 +1004,7 @@ public void testJsonContentHeaderParamsUseJsonLiteralInGeneratedTests() throws I
     }
 
-    @Test(description = "generated tests for content (application/json) header params are valid Python syntax; kept in a separate test so a missing python3 toolchain skips only this check")
+    @Test(description = "generated tests for content (application/json) header params are valid Python syntax; kept in a separate test so a missing python3 toolchain skips only this check", enabled = false)
     public void testJsonContentHeaderParamsGeneratedTestsCompile() throws IOException, InterruptedException {
         String specPath = "src/test/resources/3_0/python/connexion-json-header-test-values.yaml";
</file context>
Suggested change
@Test(description = "generated tests for content (application/json) header params are valid Python syntax; kept in a separate test so a missing python3 toolchain skips only this check", enabled = false)
@Test(description = "generated tests for content (application/json) header params are valid Python syntax; kept in a separate test so a missing python3 toolchain skips only this check")

@wing328
wing328 merged commit c60a9cf into master Nov 4, 2026
15 checks passed
@wing328
wing328 deleted the disable-python-compile-test branch November 4, 2026 09:56
@wing328 wing328 added this to the 7.28.0 milestone Nov 4, 2026
@khayashi4337

Copy link
Copy Markdown
Contributor

Thanks for flagging this, and sorry for the trouble.

I'll send a follow-up PR that:

  1. keeps the Java-only assertions of the two disabled tests (testJsonContentHeaderParamsGeneratedTestsCompile, testInfoTitleEmbeddedAsPythonStringLiteral) as regular tests, so ./mvnw test no longer needs python3, and
  2. moves the python3-based checks (py_compile of the generated controller tests, and evaluating the generated setup.py with Python's ast) into a new GitHub workflow modelled on samples-python-fastapi-server.yaml.

khayashi4337 added a commit to khayashi4337/openapi-generator that referenced this pull request Nov 6, 2026
…s test

The unit tests must not require a python3 toolchain (OpenAPITools#25556). Replace the
python3 -m py_compile check in testEscapedNamesInAttributeMapAndApiKeyHeaders
with Java assertions that pin the same guarantee: the escaped literal lines
are now matched as whole lines (assertFileContainsTrimmedLine) and
assertFileNotContains rules out the unterminated literal forms a missing
escape would emit. The assertPythonCompiles helper goes away with its only
call site, so this test no longer skips when python3 is absent.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
wing328 pushed a commit that referenced this pull request Nov 9, 2026
…oolchain (#25579)

The unit tests must not require a python3 toolchain (#25556), so the
python3-based checks are removed or replaced with Java assertions:

- testJsonContentHeaderParamsGeneratedTestsCompile is removed; it only
  ran `python3 -m py_compile` on the generated test file, which needs
  the optional toolchain the unit tests must not depend on.
- testInfoTitleEmbeddedAsPythonStringLiteral is re-enabled with
  Java-only assertions, tightened to whole-line
  assertFileContainsTrimmedLine checks for the setup.py kwargs literals
  in all four variants. The python3 helpers that evaluated setup()
  kwargs via ast and compiled generated tests via py_compile
  (assertSetupPyValuesMatchSpec, assertPythonSyntaxValid) are removed
  with it.

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
wing328 pushed a commit that referenced this pull request Nov 11, 2026
…pe names inside generated Python string literals (#25457)

* fix(python-flask, python-aiohttp, python-blueplanet): don't HTML-escape names inside generated Python string literals

Mustache's {{...}} HTML-escapes its value. The Connexion server templates
wrote property and parameter names into Python string literals that way,
so a model property named 'a&b' produced attribute_map 'ab': 'a&amp;b'
and from_dict() silently dropped its value. A ' in a name gave '&#39;'.

These names are now rendered with {{{...}}} from vendor extensions that
hold them escaped for a single-quoted Python literal, losslessly
(backslash, quote, newline, CR, tab and other control characters):
- model attribute_map (python-flask, python-aiohttp, python-blueplanet);
- query keys in the generated controller tests (python-flask,
  python-aiohttp), and header names in python-blueplanet's generated
  tests. Parameters get x-python-connexion-quoted-name, the same name and
  meaning as in #25427, which covers the header/cookie lookups in the
  python-flask/python-aiohttp controllers and tests.

The generated tests also sent an apiKey under the security scheme's name
instead of the header name (keyParamName). They now send keyParamName,
and only for apiKeys in a header. Query/cookie apiKeys are not sent, as
before.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Unify fromSecurity merge and keep wire names in generated tests

Merge the two fromSecurity overrides produced by the upstream merge so
both the security-function-suffix and quoted-key-param-name extensions
are set. Emit the escaped wire name (openapi-name or baseName) for
query params and apiKey-in-query entries in x-test-query-string, and
update the escaped-names test to expect the apikey query credential
that the new upstream behavior correctly sends.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* Render query names unescaped in generated controller tests

Mustache HTML-escapes {{name}}, so wire names containing &, ', <, > or "
were rendered as entities and the second query_string assignment sent the
escaped name instead of the real one. Use {{{name}}} like the other
string interpolations in these templates.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(python-blueplanet): don't HTML-escape header, cookie, and query names in the generated controller and test

The generated blueplanet controller read headers and cookies via
connexion.request.headers.get('{{baseName}}') / cookies.get('{{baseName}}'),
and the generated test sent query parameters under the sanitized
{{paramName}}. {{baseName}} is HTML-escaped by mustache, so names such as
"X-A&B'Head" or "X-C&oo'kie" were emitted as "X-A&amp;B&#39;Head" and the
lookup could never match; the query test line sent the sanitized name
("qwes") instead of the wire name ("q&we's").

Use the x-python-connexion-quoted-name vendor extension (already populated
for every parameter by AbstractPythonConnexionServerCodegen) in all three
places, matching python-flask and python-aiohttp. Add a cookie parameter to
the escaped-names test spec, assert the generated controller and test emit
the original names escaped for single-quoted Python literals, and py_compile
the generated controller and test.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* [python] Drop the python3 toolchain requirement from the escaped-names test

The unit tests must not require a python3 toolchain (#25556). Replace the
python3 -m py_compile check in testEscapedNamesInAttributeMapAndApiKeyHeaders
with Java assertions that pin the same guarantee: the escaped literal lines
are now matched as whole lines (assertFileContainsTrimmedLine) and
assertFileNotContains rules out the unterminated literal forms a missing
escape would emit. The assertPythonCompiles helper goes away with its only
call site, so this test no longer skips when python3 is absent.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants