Skip to content

Commit 9f4efb4

Browse files
authored
Merge pull request #154 from jagerman/test-suite-fix
Fix test suite use of `r.json is None`
2 parents 37856cf + 80f73a8 commit 9f4efb4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

tests/test_onion_requests.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,8 @@ def test_v4_authenticated(room, mod, client):
209209
def v4_post_body():
210210
from flask import request, jsonify, Response
211211

212-
if request.json is not None:
212+
if request.is_json:
213213
return jsonify({"json": request.json})
214-
print(f"rd: {request.data}")
215214
return Response(
216215
f"not json ({request.content_type}): {request.data.decode()}".encode(),
217216
mimetype='text/plain',
@@ -234,8 +233,10 @@ def test_v4_post_body(room, user, client):
234233

235234
info, body = decrypt_reply(r.data, v=4, enc_type="xchacha20")
236235

237-
assert info == {'code': 200, 'headers': {'content-type': 'text/plain; charset=utf-8'}}
238-
assert body == b'not json (text/plain): test data'
236+
assert (info, body) == (
237+
{'code': 200, 'headers': {'content-type': 'text/plain; charset=utf-8'}},
238+
b'not json (text/plain): test data',
239+
)
239240

240241
# Now try with json:
241242
test_json = {"test": ["json", None], "1": 23}

tests/test_routes_general.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def batch_test_endpoint3():
128128
def batch_test_endpoint4():
129129
from flask import request, jsonify, Response
130130

131-
if request.json is not None:
131+
if request.is_json:
132132
return jsonify({"echo": request.json})
133133
return Response(f"echo: {request.data.decode()}".encode(), mimetype='text/plain')
134134

0 commit comments

Comments
 (0)