Closed felixonmars closed 5 years ago
I am getting the following failures with either flask 1.0.2 or 1.0.3:
============================= test session starts ============================== platform linux -- Python 3.7.3, pytest-4.4.2, py-1.8.0, pluggy-0.11.0 rootdir: /build/python-apispec-webframeworks/src/apispec-webframeworks-0.4.0 collected 36 items apispec_webframeworks/tests/test_ext_bottle.py .......... [ 27%] apispec_webframeworks/tests/test_ext_flask.py ..FF.......... [ 66%] apispec_webframeworks/tests/test_ext_tornado.py ............ [100%] =================================== FAILURES =================================== _______________ TestPathHelpers.test_path_from_method_view[2.0] ________________ self = <apispec_webframeworks.tests.test_ext_flask.TestPathHelpers object at 0x7f4384eb5828> app = <Flask 'apispec_webframeworks.tests.test_ext_flask'> spec = <apispec.core.APISpec object at 0x7f4384eb5e48> def test_path_from_method_view(self, app, spec): class HelloApi(MethodView): """Greeting API. --- x-extension: global metadata """ def get(self): """A greeting endpoint. --- description: get a greeting responses: 200: description: said hi """ return 'hi' def post(self): return 'hi' method_view = HelloApi.as_view('hi') app.add_url_rule('/hi', view_func=method_view, methods=('GET', 'POST')) spec.path(view=method_view) expected = { 'description': 'get a greeting', 'responses': {200: {'description': 'said hi'}}, } paths = get_paths(spec) > assert paths['/hi']['get'] == expected E AssertionError: assert {'description...'said hi'})])} == {'description'...: 'said hi'}}} E Omitting 1 identical items, use -vv to show E Differing items: E {'responses': OrderedDict([('200', {'description': 'said hi'})])} != {'responses': {200: {'description': 'said hi'}}} E Use -v to get the full diff apispec_webframeworks/tests/test_ext_flask.py:76: AssertionError ______________ TestPathHelpers.test_path_from_method_view[3.0.0] _______________ self = <apispec_webframeworks.tests.test_ext_flask.TestPathHelpers object at 0x7f4384ecff98> app = <Flask 'apispec_webframeworks.tests.test_ext_flask'> spec = <apispec.core.APISpec object at 0x7f4384ecf3c8> def test_path_from_method_view(self, app, spec): class HelloApi(MethodView): """Greeting API. --- x-extension: global metadata """ def get(self): """A greeting endpoint. --- description: get a greeting responses: 200: description: said hi """ return 'hi' def post(self): return 'hi' method_view = HelloApi.as_view('hi') app.add_url_rule('/hi', view_func=method_view, methods=('GET', 'POST')) spec.path(view=method_view) expected = { 'description': 'get a greeting', 'responses': {200: {'description': 'said hi'}}, } paths = get_paths(spec) > assert paths['/hi']['get'] == expected E AssertionError: assert {'description...'said hi'})])} == {'description'...: 'said hi'}}} E Omitting 1 identical items, use -vv to show E Differing items: E {'responses': OrderedDict([('200', {'description': 'said hi'})])} != {'responses': {200: {'description': 'said hi'}}} E Use -v to get the full diff apispec_webframeworks/tests/test_ext_flask.py:76: AssertionError
Yes, this is due to a recent change in apispec. status codes are always serialized as string.
Expected response should read
'responses': {'200': {'description': 'said hi'}},
That's an easy fix.
PR welcome.
Fixed in https://github.com/marshmallow-code/apispec-webframeworks/commit/df55059d185ec3db28818f3bf099343a114e806a.
I am getting the following failures with either flask 1.0.2 or 1.0.3: