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 23d9b33, 964c4a3 · Browse files · 3 files·+20 added−2 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+20 added−2 removed
- other:+20 added−2 removed
Provenance
- Commit
9298d89- Tree
2c24a34- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
23d9b33- Parent 2
964c4a3
3 files changed+20 added−2 removed
modified:flask/testsuite/helpers.py+16 added-2 removed
302 unmodified lines303 rv.close()304 # etags305 self.assert_equal(len(captured), 1)306 with catch_warnings() as captured:307- class PyStringIO(StringIO):308- pass307+ class PyStringIO(object):308+ def __init__(self, *args, **kwargs):309+ self._io = StringIO(*args, **kwargs)310+ def __getattr__(self, name):311+ return getattr(self._io, name)312 f = PyStringIO('Test')313 f.name = 'test.txt'314 rv = flask.send_file(f)315 rv.direct_passthrough = False93 unmodified lines409 cc = parse_cache_control_header(rv.headers['Cache-Control'])410 self.assert_equal(cc.max_age, 10)411 rv.close()412 413+ def test_send_from_directory(self):414+ app = flask.Flask(__name__)415+ app.testing = True416+ app.root_path = os.path.join(os.path.dirname(__file__),417+ 'test_apps', 'subdomaintestmodule')418+ with app.test_request_context():419+ rv = flask.send_from_directory('static', 'hello.txt')420+ rv.direct_passthrough = False421+ self.assert_equal(rv.get_data().strip(), b'Hello Subdomain')422+ rv.close()423 424+425 class LoggingTestCase(FlaskTestCase):426 427 def test_logger_cache(self):428 app = flask.Flask(__name__)230 unmodified linesmodified:flask/helpers.py+2 added
613 unmodified lines614 :param options: optional keyword arguments that are directly615 forwarded to :func:`send_file`.616 """617 filename = safe_join(directory, filename)618+ if not os.path.isabs(filename):619+ filename = os.path.join(current_app.root_path, filename)620 if not os.path.isfile(filename):621 raise NotFound()622 options.setdefault('conditional', True)623 return send_file(filename, **options)238 unmodified linesmodified:CHANGES+2 added
31 unmodified lines32 - 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+- Fixed `send_from_directory` not expanding to the application root path37+ correctly.38 39 Version 0.10.140 --------------41 457 unmodified lines