Commit graph

324 commits

Author SHA1 Message Date
Hendrik Makait
3d220155b9 Check if app factory takes script_info argument and call it with(out) script_info as an argument depending on that 2017-05-23 13:48:42 -07:00
David Lord
f2a26657c3 Merge pull request #2316 from ka7eh/automatic-options-in-views
Adds provide_automatic_options to Class-based Views
2017-05-23 12:46:31 -07:00
David Lord
47717e5564 Merge pull request #2311 from bovarysme/use-yield-syntax
Use the yield syntax in pytest's fixtures
2017-05-23 12:00:34 -07:00
kaveh
24fe84adab Adds provide_automatic_options to Class-based Views 2017-05-23 11:51:13 -07:00
cerickson
145d362587 Added support for generic HTTPException handlers on app and blueprints
Error handlers are now returned in order of blueprint:code, app:code,
blueprint:HTTPException, app:HTTPException, None

Corresponding tests also added.

Ref issue #941, pr #1383, #2082, #2144
2017-05-23 10:45:42 -07:00
Florian Sachs
1b691415be Register errorhandlers for Exceptions
Allow a default errorhandler by registering
an errorhandler for HTTPException

tests included
2017-05-23 10:34:31 -07:00
bovarysme
e94527717e Use the yield syntax in pytest's fixtures 2017-05-23 18:21:29 +02:00
David Lord
739d099c15 Merge pull request #2303 from MikeTheReader/master
Added tests for make_response and get_debug_flag to improve coverage of helpers.py
2017-05-23 08:34:22 -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
Randy Liou
5152fa9b38 Add coverage for Blueprint teardown request method
Test the following methods in the Blueprint object: teardown_request,
and teardown_app_request.
This PR increases the coverage of blueprint module by 3%.
2017-05-22 16:58:04 -07:00
Randy Liou
d4c1bfaa77 Add coverage for Blueprint request process methods
Add test to cover following methodss to the Blueprint object:
before_request, after_request, before_app_request,
before_app_first_request, after_app_request.
This PR increases the coverage of flask.blueprints by 6%.
2017-05-22 16:58:04 -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
28c8a78baf Merge pull request #2297 from HndrkMkt/#2265-auto-detect-create-app-function
Auto-detect create_app() in find_best_app() #2265
2017-05-22 16:13:27 -07:00
Randy Liou
5a5de52ab0 Add coverage for Blueprint.add_app_template_global
This tests the Blueprint.add_app_template_global mothod, which internally
calls the Blueprint.app_template_global method. The methods are used to
registering a function to the jinja template environment.
This PR increases the test coverage for module flask.blueprint by 4%.
2017-05-22 14:33:58 -07:00
David Lord
6a91f8443d Merge pull request #2298 from dawran6/test-bp-context
Add coverage for Blueprints.(app_)context_processor
2017-05-22 14:01:59 -07:00
Randy Liou
19d33ecfa7 Add coverage for Blueprints.(app_)context_processor
Test both context_processor and app_context_processor functions.
Two context parameters are added into the context: one added to
the blueprint locally; another added to the app globally. The test
asserts the behaviors in both blueprint scope and the app scope.
The coverage for flask.blueprints is increased by 3%.
2017-05-22 13:09:22 -07:00
Hendrik Makait
91633c21ec Auto-detect create_app and make_app factory functions 2017-05-22 12:30:18 -07:00
Randy Liou
158290e3b0 Add coverage for Blueprint.app_errorhandler
This test case registers an application-wise error handler from
a Blueprint. Verifies the error handler by aborting the flask app
from the application itself as well as from another registered
Blueprint.
2017-05-22 12:00:04 -07:00
David Lord
298bcfaeb6 set session accessed for setdefault 2017-05-20 13:00:17 -07:00
David Lord
409c8799d4 Merge branch 'master' into vary-cookies 2017-05-19 09:44:06 -07:00
David Lord
9ada22dd94 safe_join on Windows uses posixpath
fixes #2033
closes #2059
2017-05-15 16:58:01 -07:00
David Lord
9c7e73e955 refactor session cookie domain logic
cache result of session cookie domain
add warnings for session cookie domain issues
add changelog
2017-05-13 21:59:00 -07:00
David Lord
c279a827cc add sort by match order
sort by endpoint by default
combine sort flags
sort methods
ignore HEAD and OPTIONS methods by default
rearrange columns
use format to build row format string
rework tests
add changelog
2017-04-26 10:26:59 -07:00
David Lord
57515e1887 Merge branch 'master' into routes-command 2017-04-25 13:13:10 -07:00
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