Commit graph

81 commits

Author SHA1 Message Date
Daniel Pope
ad9807891d Fix style issues on master using Black 2019-05-31 11:57:28 +01:00
EtiennePelletier
1a9616d581 Use Werkzeug's JSONMixin class and update tests
Flask's JSONMixin class was moved to Werkzeug>=0.15

Co-authored-by: Jeffrey Eliasen <jeff@jke.net>
2019-05-18 20:57:26 -07:00
David Lord
371d1ab40d clean up open_resource and tests 2019-05-17 13:23:27 -07:00
icreatedanaccount
07a177043f Allow mode='rt' on open_resource() helper 2019-05-17 13:22:13 -07:00
David Baumgold
85ce588b3b Reformat with black
https://github.com/python/black
2019-05-06 16:28:58 -04:00
David Lord
39e9ebaaee Merge remote-tracking branch 'origin/1.0-maintenance' 2019-01-07 10:00:10 -08:00
garenchan
0b182de99a Make sure the attachment filename is text type.
If attachment filename is bytes type and contains non-ascii coded bytes,
then the following ASCII encoding process will trigger
UnicodeDecodeError exception.

Fix issue #2933.
2019-01-07 07:17:33 -08:00
David Lord
fd3c2dd2f8 add changelog for GH-2957 2019-01-07 06:56:20 -08:00
Ignasi Bosch
45fbf751bc Allow partial content on bytesio 2019-01-07 06:17:36 -08:00
Matt Robenolt
0b88fbd5eb Add support for PathLike objects in static file helpers
See: https://www.python.org/dev/peps/pep-0519/

This is mostly encountered with pathlib in python 3, but this API
suggests any PathLike object can be treated like a filepath with
`__fspath__` function.
2019-01-05 15:23:47 -08:00
David Lord
40a2cecdf7 encode filenames as ascii instead of latin-1
latin-1 is allowed by pep3333, but that breaks gunicorn
2018-05-28 06:36:47 -07:00
David Lord
056c62e0b0 detect UTF encodings when loading json 2018-04-10 09:34:59 -07:00
fphonor
df23942df2 get_json separate cache depending on silent arg 2018-04-09 02:52:40 -07:00
David Lord
aa4db37a7f revert copyright year to project start
add copyright header to files
2018-02-08 12:43:30 -08:00
Armin Ronacher
a1afc8f1a7 Add Support for FLASK_ENV (#2570)
This introduces environments to Flask
2018-01-06 17:07:56 +01:00
Adrian Moennich
26cc8fba36 Fix broken test 2017-11-25 00:53:43 +01:00
Adrian Moennich
875c30bad1 Merge remote-tracking branch 'upstream/0.12-maintenance' 2017-11-25 00:44:07 +01:00
ThiefMaster
dd8adc11be Fix ValueError for some invalid Range requests
fixes #2526
2017-11-25 00:37:49 +01:00
David Lord
9acb1d2412 simplify logging configuration
single default handler and formatter
don't remove handlers
configure level once using setLevel
document logging
reorganize logging tests
2017-07-31 12:49:03 -07:00
Eugene M. Kim
015440ded5 Actually hand-spin and use a tzinfo subclass
This is for Python 2.x compatibility.

Suggested-by: David Lord <davidism@gmail.com>
2017-06-14 14:23:13 -07:00
Eugene M. Kim
fee894e9e8 Re-revert to not using pytz
Will spin a tzinfo subclass.
2017-06-14 14:14:18 -07:00
Eugene M. Kim
e8113c4b77 Skip aware datetime tests if pytz is unavailable 2017-06-14 14:08:42 -07:00
Eugene M. Kim
ed5ff89800 Use pytz again for tests
This is because datetime.timezone is Python 3 only.  The only
alternative would be to hand-spin a datetime.tzinfo subclass, an
overkill.

This reverts commit 0e6cab3576.
2017-06-14 13:57:40 -07:00
Eugene M. Kim
45bfd49231 Rewrite test_jsonify_aware_datetimes without pytz 2017-06-14 13:06:26 -07:00
Eugene M. Kim
8b3fb19a0a Add UTs for #2372
test_encode_aware_datetime() fails for non-UTC timezones due to the bug.
2017-06-14 12:22:09 -07:00
David Lord
f542c5f599 failing test for streaming session 2017-06-02 11:07:53 -07:00
David Lord
1fbe779fd2 make debugging bad key errors easier
* TRAP_BAD_REQUEST_ERRORS is enabled by default in debug mode
* BadRequestKeyError has the key in the description in debug mode

closes #382
2017-05-29 19:08:25 -07:00
Christian Stade-Schuldt
55b92efab4 More DRYing up the test suite (#2325) 2017-05-24 17:27:36 -07:00
Christian Stade-Schuldt
2158fe3e12 DRYing up the test suite using pytest fixtures (#2306)
* add fixtures to conftest.py

* use fixtures in test_appctx.py

* use fixtures in test_blueprints.py

* use fixtures in test_depreciations.py

* use fixtures in test_regressions.py

* use fixtures in test_reqctx.py

* use fixtures in test_templating.py

* use fixtures in test_user_error_handler.py

* use fixtures in test_views.py

* use fixtures in test_basics.py

* use fixtures in test_helpers.py

* use fixtures in test_testing.py

* update conftest.py

* make docstrings  PEP-257 compliant

* cleanup

* switch dictonary format

* use pytest parameterization for test_json_as_unicode
2017-05-23 15:18:39 -07:00
MikeTheReader
e81deed87a Replace double quotes with single quotes 2017-05-23 07:59:53 -07:00
MikeTheReader
87081acf0b Parameterize test_get_debug_flag 2017-05-23 07:51:57 -07:00
MikeTheReader
3e42e38485 Modifications based on review 2017-05-22 20:49:37 -07:00
MikeTheReader
2c38769336 Added tests for make_response and get_debug_flag to improve coverage of helpers.py 2017-05-22 16:15:48 -07:00
David Lord
935acefaf2 safe_join on Windows uses posixpath
fixes #2033
closes #2059
2017-05-16 08:34:37 +02:00
David Lord
9ada22dd94 safe_join on Windows uses posixpath
fixes #2033
closes #2059
2017-05-15 16:58:01 -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
151463eb57 get mtime in utc 2017-04-14 05:30:03 -07:00
David Lord
c6bb311175 get mtime in utc 2017-04-13 14:55:56 -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
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
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
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
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
830632714c Do not error for unknown files if send_file sends an actual file 2016-09-10 03:33:53 +03: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
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