Merge branch '0.10-maintenance'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parents 6f44ca7, d094d5b · Browse files · 4 files·+28 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+28 added−10 removed
- other:+28 added−10 removed
Provenance
- Commit
23d9b33- Tree
a5f39c2- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
6f44ca7- Parent 2
d094d5b
4 files changed+28 added−10 removed
modified:flask/testsuite/helpers.py+12 added
302 unmodified lines303 rv.close()304 # etags305 self.assert_equal(len(captured), 1)306 with catch_warnings() as captured:307+ class PyStringIO(StringIO):308+ pass309+ f = PyStringIO('Test')310+ f.name = 'test.txt'311+ rv = flask.send_file(f)312+ rv.direct_passthrough = False313+ self.assert_equal(rv.data, b'Test')314+ self.assert_equal(rv.mimetype, 'text/plain')315+ rv.close()316+ # attachment_filename and etags317+ self.assert_equal(len(captured), 3)318+ with catch_warnings() as captured:319 f = StringIO('Test')320 rv = flask.send_file(f, mimetype='text/plain')321 rv.direct_passthrough = False322 self.assert_equal(rv.data, b'Test')322 unmodified linesmodified:flask/testsuite/testing.py+2 added-2 removed
205 unmodified lines206 207 with app.test_client() as c:208 rv = c.post('http://domain.com/action?vodka=42', data={'gin': 43})209 self.assert_equal(rv.status_code, 200)210- self.assert_('gin' in flask.request.form)211- self.assert_('vodka' in flask.request.args)210+ self.assert_true('gin' in flask.request.form)211+ self.assert_true('vodka' in flask.request.args)212 213 214 class SubdomainTestCase(FlaskTestCase):215 41 unmodified linesmodified:flask/helpers.py+13 added-8 removed
536 unmodified lines537 rv.cache_control.max_age = cache_timeout538 rv.expires = int(time() + cache_timeout)539 540 if add_etags and filename is not None:541+ try:541- rv.set_etag('flask-%s-%s-%s' % (542- os.path.getmtime(filename),543- os.path.getsize(filename),544- adler32(545- filename.encode('utf-8') if isinstance(filename, text_type)546- else filename547- ) & 0xffffffff548- ))542+ rv.set_etag('flask-%s-%s-%s' % (543+ os.path.getmtime(filename),544+ os.path.getsize(filename),545+ adler32(546+ filename.encode('utf-8') if isinstance(filename, text_type)547+ else filename548+ ) & 0xffffffff549+ ))550+ except OSError:551+ warn('Access %s failed, maybe it does not exist, so ignore etags in '552+ 'headers' % filename, stacklevel=2)553+554 if conditional:555 rv = rv.make_conditional(request)556 # make sure we don't send x-sendfile for servers that557 # ignore the 304 status code for x-sendfile.302 unmodified linesmodified:CHANGES+1 added
30 unmodified lines31 context to be passed to teardown handlers.32 - Fixed an issue with query parameters getting removed from requests in33 the test client when absolute URLs were requested.34 - Made `@before_first_request` into a decorator as intended.35+- Fixed an etags bug when sending a file streams with a name.36 37 Version 0.10.138 --------------39 457 unmodified lines