1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
Description: Handle change of HTTP response code text in Python 3.13
Forwarded: https://github.com/sphinx-contrib/openapi/pull/162
Author: Julian Gilbey <jdg@debian.org>
Last-Update: 2024-11-19
--- a/tests/renderers/httpdomain/test_render_response.py
+++ b/tests/renderers/httpdomain/test_render_response.py
@@ -1,11 +1,18 @@
"""OpenAPI spec renderer: render_response."""
+import sys
import textwrap
import pytest
from sphinxcontrib.openapi import renderers
+if sys.version_info[:2] >= (3, 13):
+ http_422_description = "Unprocessable Content"
+else:
+ http_422_description = "Unprocessable Entity"
+
+
def textify(generator):
return "\n".join(generator)
@@ -218,7 +225,7 @@
pytest.param("301", "Moved Permanently", id="301"),
pytest.param("307", "Temporary Redirect", id="307"),
pytest.param("401", "Unauthorized", id="401"),
- pytest.param("422", "Unprocessable Entity", id="422"),
+ pytest.param("422", http_422_description, id="422"),
],
)
def test_render_response_content_custom(fakestate, oas_fragment, status_code, status):
--- a/tests/renderers/httpdomain/test_render_response_example.py
+++ b/tests/renderers/httpdomain/test_render_response_example.py
@@ -1,5 +1,6 @@
"""OpenAPI spec renderer: render_response_example."""
+import sys
import textwrap
import pytest
@@ -8,6 +9,12 @@
from sphinxcontrib.openapi import renderers
+if sys.version_info[:2] >= (3, 13):
+ http_422_description = "Unprocessable Content"
+else:
+ http_422_description = "Unprocessable Entity"
+
+
def textify(generator):
return "\n".join(generator)
@@ -499,7 +506,7 @@
[
pytest.param("201", "Created", id="201"),
pytest.param("307", "Temporary Redirect", id="307"),
- pytest.param("422", "Unprocessable Entity", id="422"),
+ pytest.param("422", http_422_description, id="422"),
],
)
def test_render_response_status_code(
@@ -577,7 +584,7 @@
[
pytest.param("201", "Created", id="201"),
pytest.param("307", "Temporary Redirect", id="307"),
- pytest.param("422", "Unprocessable Entity", id="422"),
+ pytest.param("422", http_422_description, id="422"),
],
)
def test_render_response_status_code_int(
|