Commit graph

296 commits

Author SHA1 Message Date
David Lord
b54d8cfc5b refactor make_response to be easier to follow
* be explicit about how tuples are unpacked
* allow bytes for status value
* allow Headers for headers value
* use TypeError instead of ValueError
* errors are more descriptive
* document that view must not return None
* update documentation about return values
* test more response types
* test error messages

closes #1676
2017-04-25 08:30:48 -07:00
David Lord
6bed207562 clean up blueprint json support
add changelog for #1898
2017-04-24 10:16:50 -07:00
David Lord
07ae566f22 Merge pull request #1898 from RaHus/per_blueprint_jsoncoding_#1710
Per blueprint jsoncoding #1710
2017-04-24 10:16:20 -07:00
David Lord
e7bc408877 ensure error while opening session pops context
errors will be handled by the app error handlers
closes #1538, closes #1528
2017-04-22 13:57:04 -07:00
David Lord
c89b732323 Merge branch 'master' into figome-multiple-inheritance 2017-04-21 10:33:29 -07:00
David Lord
3f10dd52c6 update changelog
move test next to existing test, rename
reword / reflow param doc
2017-04-21 07:26:30 -07:00
David Lord
3d22b81edf Merge branch 'master' into jrmccarthy-master 2017-04-21 07:03:46 -07:00
David Lord
a2acabcc3f add test for build error special values 2017-04-20 08:52:37 -07:00
David Lord
ffa31f1ee4 Merge pull request #1886 from dawran6/test_bp_endpoint_dec
Enhance code coverage for Blueprint.endpoint
2017-04-14 09:22:12 -07:00
David Lord
c6bb311175 get mtime in utc 2017-04-13 14:55:56 -07:00
David Lord
8f993422f0 Merge pull request #2223 from antlarr/master
Fix send_file's attachment_filename to work with non-ascii filenames
2017-04-08 10:54:20 -07:00
David Lord
01e6088c41 need to test against raw header
parsing prefers the last value parsed for the option
2017-04-08 10:33:06 -07:00
David Lord
100863e4fd style cleanup
break out header parts in test
test for no filename* parameter for ascii header
2017-04-07 18:02:31 -07:00
jab
8a2db3db18 Change Flask.__init__ to accept two new keyword arguments, host_matching and static_host. (#1560)
This enables host_matching to be set properly by the time the constructor adds
the static route, and enables the static route to be properly associated with
the required host.

Previously, you could only enable host_matching once your app was already
instantiated (e.g. app.url_map.host_matching = True), but at that point
the constructor would have already added the static route without host matching
and an associated host, leaving the static route in a broken state.

Fixes #1559.
2017-04-07 16:31:54 +02:00
Markus Unterwaditzer
6b38678139 Merge branch '0.12-maintenance' 2017-03-31 18:44:33 +02:00
Markus Unterwaditzer
247a0c906d Revert "Handle BaseExceptions (#2222)"
This reverts commit 1d4448abe3.
2017-03-31 18:44:14 +02:00
Diggory Blake
65cf64e019 Make test more idiomatic 2017-03-31 18:40:46 +02:00
Diggory Blake
965d444e0f Add test and changes 2017-03-31 18:40:46 +02:00
Diggory Blake
2774221987 Handle BaseExceptions (#2222)
* Handle BaseExceptions

* Add test and changes

* Make test more idiomatic
2017-03-31 18:07:43 +02:00
Antonio Larrosa
5e8ac066e4 Fix previous commits to work with python 2 and python 3
Also, parse_options_header seems to interpret filename* so we better
test the actual value used in the headers (and since it's valid
in any order, use a set to compare)
2017-03-24 20:05:01 +01:00
Antonio Larrosa
0d07974a49 Fix send_file to work with non-ascii filenames
This commit implements https://tools.ietf.org/html/rfc2231#section-4 in
order to support sending unicode characters. Tested on both Firefox and
Chromium under Linux.

This adds unidecode as a dependency, which might be relaxed by using
.encode('latin-1', 'ignore') but wouldn't be as useful.

Also, added a test for the correct headers to be added.

Previously, using a filename parameter to send_file with unicode characters, it
failed with the next error since HTTP headers don't allow non latin-1 characters.
Error on request:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/werkzeug/serving.py", line 193, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python3.6/site-packages/werkzeug/serving.py", line 186, in execute
    write(b'')
  File "/usr/lib/python3.6/site-packages/werkzeug/serving.py", line 152, in write
    self.send_header(key, value)
  File "/usr/lib64/python3.6/http/server.py", line 509, in send_header
    ("%s: %s\r\n" % (keyword, value)).encode('latin-1', 'strict'))
UnicodeEncodeError: 'latin-1' codec can't encode character '\uff0f' in position 58: ordinal not in range(256)

Fixes #1286
2017-03-23 17:30:48 +01:00
Ed Brannin
9c40039620 Fix CLI test for ImportError -> NoAppException 2017-03-21 16:17:09 -04:00
Sven-Hendrik Haase
edd6e3154d Add test to showcase that printing a traceback works 2017-03-16 20:56:12 +01:00
Hsiaoming Yang
9c5f048ad2 Don't rely on X-Requested-With for pretty print json response (#2193)
* Don't rely on X-Requested-With for pretty print json response

* Fix test cases for pretty print json patch

* Fix gramma error in docs for pretty print json config

* Add changelog for JSONIFY_PRETTYPRINT_REGULAR
2017-03-07 10:09:46 +09:00
David Lord
7af6c7fa97 add test and changelog for SERVER_NAME app.run default
ref #2152
2017-01-17 14:08:33 -08:00
Andrew Arendt
9f0db54689 Added python3.6 support for tests 2017-01-10 11:20:53 -06:00
Paul Brown
74a0eee5a1 prevent NoAppException when ImportError occurs within imported module 2016-12-30 22:45:53 +01:00
Markus Unterwaditzer
5512e424b6 Fix config.from_pyfile on Python 3 (#2123)
* Fix config.from_pyfile on Python 3

Fix #2118

* Support Python 2.6

* Fix tests on Python 2
2016-12-26 03:50:47 +01:00
Jiri Kuncar
cb001d3ad0 Ignore cache on request.get_json(cache=False) call (#2089)
* Test cache argument of Request.get_json

* Ignore cache on request.get_json(cache=False) call

Removes usage of `_cached_json` property when `get_json` is called with
disabled cache argument. (closes #2087)
2016-12-21 21:08:38 +01:00
Alex Kahan
279a925ab8 Parameterizing test (#2073) 2016-11-03 10:11:24 -07:00
Michael Recachinas
3f6ddf9cfd Default environ (#2047)
* Add init to FlaskClient

This addresses #1467. The init in the subclass
can now take in `environ_base`, which will then get
passed to `make_test_environ_builder` and to
`EnvironBuilder` via keyword args.

This should provide the default environment capability
on `app.test_client()` init.

* Add kwarg `environ_base` to `make_test_environ_builder` call

This change now passes `environ_base` from either
`kwargs` in `FlaskClient.open` or `FlaskClient.environ_base`
if passed into the init.

* Fix assignment reference typo

* Add default `environ_base` to `FlaskClient.__init__`

* Set default kwargs for `environ_base` in `FlaskClient.open`

* Remove specific environ_base kwarg since its in kwargs

* Add docstring to FlaskClient detailing environ_base

* Document app.test_client default environ in CHANGES

* Re-word environ_base changes in FlaskClient docstring

* Add client.environ_base tests

* Mention preset default environ in `app.test_client`

* Add versionchanged directive to docstring in FlaskClient
2016-10-12 08:54:24 +02:00
Joël Charles
f2b945d586 make use of range requests if available in werkzeug (#2031)
* make use of range requests if available in werkzeug

* different logic for testing werkzeug functionality
2016-09-26 12:43:46 +02:00
Armin Ronacher
3d68fba011 Merge pull request #2019 from pallets/bugfix/sendfile-error
Do not cause errors for unknown files for sendfile
2016-09-12 21:52:42 +03:00
Armin Ronacher
830632714c Do not error for unknown files if send_file sends an actual file 2016-09-10 03:33:53 +03:00
Armin Ronacher
a7fbfb387f Corrected after response for error handlers
Before this change after request functions were not correctly
invoked for error handlers.
2016-09-08 11:56:02 +03:00
Markus Unterwaditzer
ec9e9c2f6e Don't passthrough_errors unless instructed. (#2006)
Fix #2005

Revert #1679 and #1996
2016-09-06 22:32:34 +02:00
Roman
ae649aacaf Fix error in send_file helper (#2003)
* Fix error in send_file (mimetype_filename is not defined)

* fix formatting error message in send_file
2016-09-04 16:28:05 -07:00
Markus Unterwaditzer
2a5061282b Only passthrough_errors if PROPAGATE_EXCEPTIONS
See pallets/werkzeug#954
2016-08-27 14:38:13 +02:00
Markus Unterwaditzer
a9757f8b1e Properly remove f.name usage in send_file (#1988)
* Properly remove f.name usage in send_file

* Update changelogs

* Fix tests
2016-08-26 03:08:03 +02:00
David Lord
1584022d0b clean up new json tests 2016-08-21 08:47:12 -07:00
Nathan Land
03104555cb Add tests for flask.json.dump() and test that jsonify correctly converts uuids. 2016-08-21 07:48:05 -07:00
Anton Sarukhanov
1832130c2e Add test for get_version (CLI) (#1884) 2016-08-20 17:43:58 +02:00
Nate Prewitt
9608198047 adding in try around __import__ to catch invalid files/paths (#1950) 2016-08-12 15:12:00 +02:00
Hyunchel Kim
6179f41fd9 Enhance tests.test_cli.test_find_best_app (#1882)
This commit adds a test case for `test_find_best_app` where
Module object does not contain Flask application.
Also cleans the function little bit to provides more meaningful comment.
2016-07-05 12:46:01 -07:00
Antoine Catton
d142584973 Add the ability to combine MethodViews 2016-06-28 17:35:39 +02:00
RamiC
ba6e6a61cc Check for a request ctx before using the request.
Use the app json coder when blueprint json coder is set to none.
Revert the failling test to using an app_context
re #1710
2016-06-08 12:58:56 +03:00
RamiC
6c37f40c34 Allow per blueprint json encoder decoder
re #1710
2016-06-08 12:03:26 +03:00
Anton Sarukhanov
a4f9c63bb2 Add test for find_default_import_path 2016-06-07 08:03:55 -04:00
David Lord
2560444f47 pass value directly to last_modified 2016-06-05 12:42:34 -07:00
Prachi Shirish Khadke
cd408cc462 Add last_modified arg for send_file
Enhancement: Add last_modified arg of type DateTime to send_file.

Fixes pallets/flask#1321
2016-06-05 10:59:17 -07:00