Uh oh!
There was an error while loading. Please reload this page.
Extend test suite and remove deprecated code - #133
Conversation
Just realized the low coverage was due to pytest-cov reporting Our actual coverage looks much better Regardless, deprecated code still needs to be removed and there are some small changes I would like to propose concerning how our code is currently organized, so I'll keep working on the PR. |
pytest-cov was reporting all |
nicoddemus
commented
Feb 18, 2021
Agreed, when testing plugins and pytest itself, often is better to use |
From werkzeug changelogs
Werkzeug 2.0.0 fails our pre build Following is the test that was failing and the error deftest_request_ctx_is_kept_around(self, client):
client.get(url_for("index"), headers=[("X-Something", "42")])
assertrequest.headers["X-Something"] =="42"It seems the request context is not persisting and because of that the headers are not being found in the WSGI environ. For now I have just documented the code since I'm not sure how big of a change handling this will entail and it's probably out of this PR's scope. deftest_request_ctx_is_kept_around(self, client):
res=client.get(url_for("index"), headers=[("X-Something", "42")])
"""In werkzeug 2.0.0 the test Client provides a new attribute 'request' in the response class which holds a reference to the request object that produced the respective response, making introspection easier"""try:
assertres.request.headers["X-Something"] =="42"exceptAttributeError:
"""This is the conventional (pre 2.0.0) way of reaching the request object, using flask.request global."""assertrequest.headers["X-Something"] =="42"Suggestions are welcome in case anyone feels like jumping in |
northernSage
commented
Feb 19, 2021
Also, the |
northernSage
commented
Feb 20, 2021
It appears Werkzeug's response class now has its own json property that does exactly what our JSONResponse.json does. The That's how our coverage looks like at the moment
Almost there 👍🏻 |
nicoddemus
left a comment
There was a problem hiding this comment.
I did not review everything in detail, but seems good overall. Great work!
Uh oh!
There was an error while loading. Please reload this page.
This PR aims to extend our current test suite, getting coverage up to 100%. Also,
live_server.urlmethod has been deprecated for quite a while now, I'll probably remove it and roll the changes in this PR as well. Having better coverage will help sorting out changes proposed in #47 which touch some core functionality.request_ctxfixtureJSONResponse.jsonsince the functionality is now natively provided