Skip to content

Commit

Permalink
Clean up syntax a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosagent committed Apr 1, 2016
1 parent b4dd92d commit 69ecee4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 1 addition & 3 deletions flask/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,7 @@ def download_file(filename):
try:
if not os.path.isfile(filename):
raise NotFound()
except TypeError:
raise BadRequest()
except ValueError:
except (TypeError, ValueError):
raise BadRequest()
options.setdefault('conditional', True)
return send_file(filename, **options)
Expand Down
10 changes: 3 additions & 7 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,9 @@ def test_send_from_directory_bad_request(self):
app.testing = True
app.root_path = os.path.join(os.path.dirname(__file__),
'test_apps', 'subdomaintestmodule')
with app.test_request_context():
try:
rv = flask.send_from_directory('static', 'bad\x00')
rv.close()
assert False
except BadRequest:
pass
with app.test_request_context(), pytest.raises(BadRequest):
rv = flask.send_from_directory('static', 'bad\x00')
rv.close()

class TestLogging(object):

Expand Down

0 comments on commit 69ecee4

Please sign in to comment.