From ea3b6a6e4aa77b381ea1055e1958aa5cc7629208 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 12 Apr 2026 18:07:11 -0400 Subject: [PATCH] Fix test assertions that could never fail - test_background_task_exception: `or True` made assert always pass - test_form_uploads_without_multipart: `or r.status_code < 500` masked wrong expected value (dict() of QueryDict returns lists, not scalars) - test_graphql_text_query: `< 500` replaced with exact `== 200` Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/test_coverage.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_coverage.py b/tests/test_coverage.py index a0a2f33..437d635 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -85,7 +85,7 @@ def test_background_task_exception(capsys): time.sleep(0.2) # let the done callback fire captured = capsys.readouterr() - assert "ValueError" in captured.err or True # traceback goes to stderr + assert "ValueError" in captured.err or "ValueError" in captured.out def test_background_run(): @@ -112,7 +112,8 @@ def test_form_uploads_without_multipart(api): content="name=hello&value=world", headers={"Content-Type": "application/x-www-form-urlencoded"}, ) - assert r.json() == {"name": "world", "value": "world"} or r.status_code < 500 + assert r.status_code == 200 + assert r.json() == {"name": ["hello"], "value": ["world"]} # --- models.py coverage --- @@ -469,7 +470,7 @@ def test_graphql_text_query(api): content="{ hello }", headers={"Content-Type": "text/plain"}, ) - assert r.status_code < 500 + assert r.status_code == 200 def test_openapi_info_fields():