From 33b39e0ee1a955d56df488a188c86fe3bc2ea8ed Mon Sep 17 00:00:00 2001 From: hejl Date: Tue, 30 Aug 2022 10:44:52 +0800 Subject: [PATCH] fix test base_response data key --- tests/test_base_response.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/test_base_response.py b/tests/test_base_response.py index 1adb4ec9..6a4e6a35 100644 --- a/tests/test_base_response.py +++ b/tests/test_base_response.py @@ -117,10 +117,7 @@ def foo(): assert schema['$ref'] == schema_ref -# TODO pytest seems can't catch the ValueError happened in the output decorator def test_base_response_data_key(app, client): - pytest.skip() - app.config['BASE_RESPONSE_SCHEMA'] = BaseResponse app.config['BASE_RESPONSE_DATA_KEY '] = 'data' @@ -130,8 +127,9 @@ def foo(): data = {'id': '123', 'name': 'test'} return {'message': 'Success.', 'status_code': '200', 'info': data} - with pytest.raises(ValueError): - client.get('/') + with app.test_request_context('/'): + with pytest.raises(RuntimeError, match=r'The data key.*is not found in the returned dict.'): + foo() def test_base_response_204(app, client):