Skip to content
Myr

Eliminate some resource warnings

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parent 293eb58 · Browse files · 3 files+26 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+26 added−19 removed

  • tests:+26 added−19 removed

3 files+26 added−19 removed

modified:tests/conftest.py+2 added
5 unmodified lines
6 :copyright: (c) 2015 by the Flask Team, see AUTHORS for more details.7 :license: BSD, see LICENSE for more details.8"""9import flask10import gc11import os12import sys13import pkgutil14import pytest
114 unmodified lines
129130@pytest.yield_fixture(autouse=True)131def catch_deprecation_warnings(recwarn):132 yield133 gc.collect()134 assert not recwarn.list
modified:tests/test_basic.py+4 added
1121 unmodified lines
11221123 app.testing = True1124 rv = app.test_client().get('/foo/index.html')1125 assert rv.status_code == 2001126 rv.close()11271128 with app.test_request_context():1129 assert flask.url_for('static', filename='index.html') == '/foo/index.html'11301131
1 unmodified line
1133 app = flask.Flask(__name__, static_url_path='/foo')1134 app.testing = True1135 rv = app.test_client().get('/foo/index.html')1136 assert rv.status_code == 2001137 rv.close()11381139 with app.test_request_context():1140 assert flask.url_for('static', filename='index.html') == '/foo/index.html'11411142
512 unmodified lines
modified:tests/test_helpers.py+20 added-19 removed
351 unmodified lines
352 def test_send_file_object(self, recwarn):353 app = flask.Flask(__name__)354355 with app.test_request_context():356 f = open(os.path.join(app.root_path, 'static/index.html'), mode='rb')357 rv = flask.send_file(f)358 rv.direct_passthrough = False359 with app.open_resource('static/index.html') as f:360 assert rv.data == f.read()361 assert rv.mimetype == 'text/html'362 rv.close()356 with open(os.path.join(app.root_path, 'static/index.html'), mode='rb') as f:357 rv = flask.send_file(f)358 rv.direct_passthrough = False359 with app.open_resource('static/index.html') as f:360 assert rv.data == f.read()361 assert rv.mimetype == 'text/html'362 rv.close()363364 # mimetypes + etag365 recwarn.pop(DeprecationWarning)366 recwarn.pop(DeprecationWarning)367368 app.use_x_sendfile = True369370 with app.test_request_context():371 f = open(os.path.join(app.root_path, 'static/index.html'))372 rv = flask.send_file(f)373 assert rv.mimetype == 'text/html'374 assert 'x-sendfile' in rv.headers375 assert rv.headers['x-sendfile'] == \376 os.path.join(app.root_path, 'static/index.html')377 rv.close()371 with open(os.path.join(app.root_path, 'static/index.html')) as f:372 rv = flask.send_file(f)373 assert rv.mimetype == 'text/html'374 assert 'x-sendfile' in rv.headers375 assert rv.headers['x-sendfile'] == \376 os.path.join(app.root_path, 'static/index.html')377 rv.close()378379 # mimetypes + etag380 recwarn.pop(DeprecationWarning)381 recwarn.pop(DeprecationWarning)
51 unmodified lines
433434 def test_attachment(self, recwarn):435 app = flask.Flask(__name__)436 with app.test_request_context():437 f = open(os.path.join(app.root_path, 'static/index.html'))438 rv = flask.send_file(f, as_attachment=True)439 value, options = parse_options_header(rv.headers['Content-Disposition'])440 assert value == 'attachment'441 rv.close()437 with open(os.path.join(app.root_path, 'static/index.html')) as f:438 rv = flask.send_file(f, as_attachment=True)439 value, options = \440 parse_options_header(rv.headers['Content-Disposition'])441 assert value == 'attachment'442 rv.close()443444 # mimetypes + etag445 assert len(recwarn.list) == 2446 recwarn.clear()
304 unmodified lines