Extend test suite and remove deprecated code#133
Extend test suite and remove deprecated code#133northernSage merged 36 commits intopytest-dev:masterfrom
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 |
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 def test_request_ctx_is_kept_around(self, client):
client.get(url_for("index"), headers=[("X-Something", "42")])
assert request.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. def test_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:
assert res.request.headers["X-Something"] == "42"
except AttributeError:
"""This is the conventional (pre 2.0.0) way of reaching the
request object, using flask.request global."""
assert request.headers["X-Something"] == "42"Suggestions are welcome in case anyone feels like jumping in |
|
Also, the |
|
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!
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