Skip to content

Commit e9b189e

Browse files
authored
✅ Improve test debugging (fastapi#1222)
1 parent 483bce3 commit e9b189e

File tree

144 files changed

+434
-434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+434
-434
lines changed

docs_src/sql_databases/sql_app/tests/test_sql_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ def test_create_user():
3434
"/users/",
3535
json={"email": "deadpool@example.com", "password": "chimichangas4life"},
3636
)
37-
assert response.status_code == 200
37+
assert response.status_code == 200, response.text
3838
data = response.json()
3939
assert data["email"] == "deadpool@example.com"
4040
assert "id" in data
4141
user_id = data["id"]
4242

4343
response = client.get(f"/users/{user_id}")
44-
assert response.status_code == 200
44+
assert response.status_code == 200, response.text
4545
data = response.json()
4646
assert data["email"] == "deadpool@example.com"
4747
assert data["id"] == user_id

tests/test_additional_properties.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ def foo(items: Items):
100100

101101
def test_additional_properties_schema():
102102
response = client.get("/openapi.json")
103-
assert response.status_code == 200
103+
assert response.status_code == 200, response.text
104104
assert response.json() == openapi_schema
105105

106106

107107
def test_additional_properties_post():
108108
response = client.post("/foo", json={"items": {"foo": 1, "bar": 2}})
109-
assert response.status_code == 200
109+
assert response.status_code == 200, response.text
110110
assert response.json() == {"foo": 1, "bar": 2}

tests/test_additional_response_extra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ def read_item():
4242

4343
def test_openapi_schema():
4444
response = client.get("/openapi.json")
45-
assert response.status_code == 200
45+
assert response.status_code == 200, response.text
4646
assert response.json() == openapi_schema
4747

4848

4949
def test_path_operation():
5050
response = client.get("/items/")
51-
assert response.status_code == 200
51+
assert response.status_code == 200, response.text
5252
assert response.json() == {"id": "foo"}

tests/test_additional_responses_custom_validationerror.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@ async def a(id):
9696

9797
def test_openapi_schema():
9898
response = client.get("/openapi.json")
99-
assert response.status_code == 200
99+
assert response.status_code == 200, response.text
100100
assert response.json() == openapi_schema

tests/test_additional_responses_default_validationerror.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ async def a(id):
8181

8282
def test_openapi_schema():
8383
response = client.get("/openapi.json")
84-
assert response.status_code == 200
84+
assert response.status_code == 200, response.text
8585
assert response.json() == openapi_schema

tests/test_additional_responses_response_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@ async def b():
113113

114114
def test_openapi_schema():
115115
response = client.get("/openapi.json")
116-
assert response.status_code == 200
116+
assert response.status_code == 200, response.text
117117
assert response.json() == openapi_schema

tests/test_additional_responses_router.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,23 @@ async def c():
8989

9090
def test_openapi_schema():
9191
response = client.get("/openapi.json")
92-
assert response.status_code == 200
92+
assert response.status_code == 200, response.text
9393
assert response.json() == openapi_schema
9494

9595

9696
def test_a():
9797
response = client.get("/a")
98-
assert response.status_code == 200
98+
assert response.status_code == 200, response.text
9999
assert response.json() == "a"
100100

101101

102102
def test_b():
103103
response = client.get("/b")
104-
assert response.status_code == 200
104+
assert response.status_code == 200, response.text
105105
assert response.json() == "b"
106106

107107

108108
def test_c():
109109
response = client.get("/c")
110-
assert response.status_code == 200
110+
assert response.status_code == 200, response.text
111111
assert response.json() == "c"

tests/test_application.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ def test_get_path(path, expected_status, expected_response):
11281128

11291129
def test_swagger_ui():
11301130
response = client.get("/docs")
1131-
assert response.status_code == 200
1131+
assert response.status_code == 200, response.text
11321132
assert response.headers["content-type"] == "text/html; charset=utf-8"
11331133
assert "swagger-ui-dist" in response.text
11341134
assert (
@@ -1139,13 +1139,13 @@ def test_swagger_ui():
11391139

11401140
def test_swagger_ui_oauth2_redirect():
11411141
response = client.get("/docs/oauth2-redirect")
1142-
assert response.status_code == 200
1142+
assert response.status_code == 200, response.text
11431143
assert response.headers["content-type"] == "text/html; charset=utf-8"
11441144
assert "window.opener.swaggerUIRedirectOauth2" in response.text
11451145

11461146

11471147
def test_redoc():
11481148
response = client.get("/redoc")
1149-
assert response.status_code == 200
1149+
assert response.status_code == 200, response.text
11501150
assert response.headers["content-type"] == "text/html; charset=utf-8"
11511151
assert "redoc@next" in response.text

tests/test_custom_swagger_ui_redirect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async def read_items():
1616

1717
def test_swagger_ui():
1818
response = client.get("/docs")
19-
assert response.status_code == 200
19+
assert response.status_code == 200, response.text
2020
assert response.headers["content-type"] == "text/html; charset=utf-8"
2121
assert "swagger-ui-dist" in response.text
2222
print(client.base_url)
@@ -28,7 +28,7 @@ def test_swagger_ui():
2828

2929
def test_swagger_ui_oauth2_redirect():
3030
response = client.get(swagger_ui_oauth2_redirect_url)
31-
assert response.status_code == 200
31+
assert response.status_code == 200, response.text
3232
assert response.headers["content-type"] == "text/html; charset=utf-8"
3333
assert "window.opener.swaggerUIRedirectOauth2" in response.text
3434

tests/test_dependency_cache.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,28 @@ async def get_sub_counter_no_cache(
4141
def test_normal_counter():
4242
counter_holder["counter"] = 0
4343
response = client.get("/counter/")
44-
assert response.status_code == 200
44+
assert response.status_code == 200, response.text
4545
assert response.json() == {"counter": 1}
4646
response = client.get("/counter/")
47-
assert response.status_code == 200
47+
assert response.status_code == 200, response.text
4848
assert response.json() == {"counter": 2}
4949

5050

5151
def test_sub_counter():
5252
counter_holder["counter"] = 0
5353
response = client.get("/sub-counter/")
54-
assert response.status_code == 200
54+
assert response.status_code == 200, response.text
5555
assert response.json() == {"counter": 1, "subcounter": 1}
5656
response = client.get("/sub-counter/")
57-
assert response.status_code == 200
57+
assert response.status_code == 200, response.text
5858
assert response.json() == {"counter": 2, "subcounter": 2}
5959

6060

6161
def test_sub_counter_no_cache():
6262
counter_holder["counter"] = 0
6363
response = client.get("/sub-counter-no-cache/")
64-
assert response.status_code == 200
64+
assert response.status_code == 200, response.text
6565
assert response.json() == {"counter": 2, "subcounter": 1}
6666
response = client.get("/sub-counter-no-cache/")
67-
assert response.status_code == 200
67+
assert response.status_code == 200, response.text
6868
assert response.json() == {"counter": 4, "subcounter": 3}

0 commit comments

Comments
 (0)