Skip to content

Commit 872cc97

Browse files
committed
add test for not always calling got_request_exception
1 parent 4893b79 commit 872cc97

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_errors.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,27 @@ def record(sender, exception):
444444
finally:
445445
got_request_exception.disconnect(record, app)
446446

447+
def test_handle_error_signal_does_not_call_got_request_exception(self, app):
448+
api = restx.Api(app)
449+
450+
exception = BadRequest()
451+
452+
recorded = []
453+
454+
def record(sender, exception):
455+
recorded.append(exception)
456+
457+
@api.errorhandler(BadRequest)
458+
def handle_bad_request(error):
459+
return {"message": str(error), "value": "test"}, 400
460+
461+
got_request_exception.connect(record, app)
462+
try:
463+
api.handle_error(exception)
464+
assert len(recorded) == 0
465+
finally:
466+
got_request_exception.disconnect(record, app)
467+
447468
def test_handle_error(self, app):
448469
api = restx.Api(app)
449470

0 commit comments

Comments
 (0)