Remove deprecation warnings for add_etags & mimetype guessing for send_file()

Fix #1849
This commit is contained in:
Dan Sully 2016-06-02 10:04:48 -07:00 committed by Markus Unterwaditzer
parent 3d72099dcd
commit 8458cc5cd1
4 changed files with 14 additions and 50 deletions

View file

@ -349,7 +349,7 @@ class TestSendfile(object):
assert rv.mimetype == 'text/html'
rv.close()
def test_send_file_object(self, recwarn):
def test_send_file_object(self):
app = flask.Flask(__name__)
with app.test_request_context():
@ -361,10 +361,6 @@ class TestSendfile(object):
assert rv.mimetype == 'text/html'
rv.close()
# mimetypes + etag
recwarn.pop(DeprecationWarning)
recwarn.pop(DeprecationWarning)
app.use_x_sendfile = True
with app.test_request_context():
@ -376,10 +372,6 @@ class TestSendfile(object):
os.path.join(app.root_path, 'static/index.html')
rv.close()
# mimetypes + etag
recwarn.pop(DeprecationWarning)
recwarn.pop(DeprecationWarning)
app.use_x_sendfile = False
with app.test_request_context():
f = StringIO('Test')
@ -389,9 +381,6 @@ class TestSendfile(object):
assert rv.mimetype == 'application/octet-stream'
rv.close()
# etags
recwarn.pop(DeprecationWarning)
class PyStringIO(object):
def __init__(self, *args, **kwargs):
self._io = StringIO(*args, **kwargs)
@ -405,11 +394,6 @@ class TestSendfile(object):
assert rv.mimetype == 'text/plain'
rv.close()
# attachment_filename and etags
a = recwarn.pop(DeprecationWarning)
b = recwarn.pop(DeprecationWarning)
c = recwarn.pop(UserWarning) # file not found
f = StringIO('Test')
rv = flask.send_file(f, mimetype='text/plain')
rv.direct_passthrough = False
@ -417,9 +401,6 @@ class TestSendfile(object):
assert rv.mimetype == 'text/plain'
rv.close()
# etags
recwarn.pop(DeprecationWarning)
app.use_x_sendfile = True
with app.test_request_context():
@ -428,10 +409,7 @@ class TestSendfile(object):
assert 'x-sendfile' not in rv.headers
rv.close()
# etags
recwarn.pop(DeprecationWarning)
def test_attachment(self, recwarn):
def test_attachment(self):
app = flask.Flask(__name__)
with app.test_request_context():
with open(os.path.join(app.root_path, 'static/index.html')) as f:
@ -441,10 +419,6 @@ class TestSendfile(object):
assert value == 'attachment'
rv.close()
# mimetypes + etag
assert len(recwarn.list) == 2
recwarn.clear()
with app.test_request_context():
assert options['filename'] == 'index.html'
rv = flask.send_file('static/index.html', as_attachment=True)