Use recwarn everywhere
...instead of custom fixture. Also assert that no warnings are left over after the test.
This commit is contained in:
parent
047efac537
commit
d393597c50
5 changed files with 110 additions and 92 deletions
|
|
@ -16,7 +16,7 @@ import flask
|
|||
|
||||
class TestRequestDeprecation(object):
|
||||
|
||||
def test_request_json(self, catch_deprecation_warnings):
|
||||
def test_request_json(self, recwarn):
|
||||
"""Request.json is deprecated"""
|
||||
app = flask.Flask(__name__)
|
||||
app.testing = True
|
||||
|
|
@ -27,13 +27,11 @@ class TestRequestDeprecation(object):
|
|||
print(flask.request.json)
|
||||
return 'OK'
|
||||
|
||||
with catch_deprecation_warnings() as captured:
|
||||
c = app.test_client()
|
||||
c.post('/', data='{"spam": 42}', content_type='application/json')
|
||||
c = app.test_client()
|
||||
c.post('/', data='{"spam": 42}', content_type='application/json')
|
||||
recwarn.pop(DeprecationWarning)
|
||||
|
||||
assert len(captured) == 1
|
||||
|
||||
def test_request_module(self, catch_deprecation_warnings):
|
||||
def test_request_module(self, recwarn):
|
||||
"""Request.module is deprecated"""
|
||||
app = flask.Flask(__name__)
|
||||
app.testing = True
|
||||
|
|
@ -43,8 +41,6 @@ class TestRequestDeprecation(object):
|
|||
assert flask.request.module is None
|
||||
return 'OK'
|
||||
|
||||
with catch_deprecation_warnings() as captured:
|
||||
c = app.test_client()
|
||||
c.get('/')
|
||||
|
||||
assert len(captured) == 1
|
||||
c = app.test_client()
|
||||
c.get('/')
|
||||
recwarn.pop(DeprecationWarning)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue