Skip to content
Myr

Fix error in send_file helper (#2003)

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

* Fix error in send_file (mimetype_filename is not defined) * fix formatting error message in send_file

authored by Roman · committed by David Lord · parent 96b6345 · Browse files · 2 files+7 added−3 removed
This commit

State

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

Diff stats

2 files+7 added−3 removed

  • tests:+5 added−1 removed
  • other:+2 added−2 removed

2 files+7 added−3 removed

modified:flask/helpers.py+2 added-2 removed
516 unmodified lines
517518 if mimetype is None:519 if attachment_filename is not None:520 raise ValueError(521 'Unable to infer MIME-type from filename {!r}, please '522 'pass one explicitly.'.format(mimetype_filename)521 'Unable to infer MIME-type from filename {0!r}, please '522 'pass one explicitly.'.format(attachment_filename)523 )524 raise ValueError(525 'Unable to infer MIME-type because no filename is available. '526 'Please set either `attachment_filename`, pass a filepath to '
420 unmodified lines
modified:tests/test_helpers.py+5 added-1 removed
396 unmodified lines
397398 with app.test_request_context():399 with pytest.raises(ValueError) as excinfo:400 flask.send_file(StringIO("LOL"))401401 assert 'Unable to infer MIME-type' in str(excinfo)402 assert 'no filename is available' in str(excinfo)403404 with app.test_request_context():405 with pytest.raises(ValueError) as excinfo:406 flask.send_file(StringIO("LOL"), attachment_filename='filename')407 assert "Unable to infer MIME-type from filename 'filename'" in str(excinfo)408409 def test_send_file_object(self):410 app = flask.Flask(__name__)411412 with app.test_request_context():
410 unmodified lines