Commit Graph

41 Commits

Author SHA1 Message Date
Grey Li e93704fbfd
fix url_prefix argument when nesting blueprints 2021-05-13 15:02:13 -07:00
David Lord 7c5261407d
blueprint name may not contain a dot 2021-05-13 14:31:50 -07:00
pgjones f92e820b4b
Nested blueprints
This allows blueprints to be nested within blueprints via a new
Blueprint.register_blueprint method. This should provide a use case
that has been desired for the past ~10 years.

This works by setting the endpoint name to be the blueprint names,
from parent to child delimeted by "." and then iterating over the
blueprint names in reverse order in the app (from most specific to
most general). This means that the expectation of nesting a blueprint
within a nested blueprint is met.
2021-04-14 09:25:42 -07:00
David Lord dc11cdb4a4
move send_file and send_from_directory to Werkzeug
The implementations were moved to Werkzeug, Flask's functions become
wrappers around Werkzeug to pass some Flask-specific values.

cache_timeout is renamed to max_age. SEND_FILE_MAX_AGE_DEFAULT,
app.send_file_max_age_default, and app.get_send_file_max_age defaults
to None. This tells the browser to use conditional requests rather than
a 12 hour cache.

attachment_filename is renamed to download_name, and is always sent if
a name is known.

Deprecate helpers.safe_join in favor of werkzeug.utils.safe_join.

Removed most of the send_file tests, they're tested in Werkzeug.

In the file upload example, renamed the uploaded_file view to
download_file to avoid a common source of confusion.
2020-11-05 09:27:52 -08:00
David Lord f2f027d1fb
remove unused module docstrings 2020-04-04 12:28:08 -07:00
David Lord 2ae740dd49
f-strings everywhere 2020-04-04 12:10:00 -07:00
David Lord 524fd0bc8c
apply pyupgrade 2020-04-04 12:10:00 -07:00
David Lord 662c245795
remove _compat module 2020-04-04 12:10:00 -07:00
David Lord 1351d0a565
Merge branch '1.0.x' 2019-06-23 16:57:52 -07:00
David Lord e666f7a69c
standardize license and copyright 2019-06-22 13:09:09 -07:00
David Lord 43483683b2
apply reorder-python-imports pre-commit config 2019-06-01 09:07:20 -07:00
Jon S. Stumpf b46f5942a5
address flake8 issues 2019-06-01 06:31:35 -07:00
David Baumgold 025589ee76 Reformat with black
https://github.com/python/black
2019-05-06 16:28:58 -04:00
David Lord b21b4d1608
add more merge cases 2018-05-01 13:29:48 -07:00
Hsiaoming Yang f7a3bdc6db
Fix blueprint route for "" 2018-05-01 14:35:55 +09:00
David Lord 4d0cdf95e6
merge slashes between blueprint prefix and rule 2018-04-27 12:40:06 -07:00
ThiefMaster 6663bf1f7d Fix registering partials as view functions 2018-04-27 13:44:07 +02:00
David Lord 401423df06
only strip one slash when registering blueprint
add test and changelog
2018-02-23 15:47:06 -08:00
David Lord 310fbfcf64
revert copyright year to project start
add copyright header to files
2018-02-08 12:43:30 -08:00
Caratpine 2f57a0b917
Blueprint view function name should not contain dots 2017-10-09 08:12:34 -07:00
Christian Stade-Schuldt 4ec1fbc9f5 More DRYing up the test suite (#2325) 2017-05-24 17:27:36 -07:00
David Lord 849fc4b90c Merge pull request #2323 from dawran6/test-fixture
Cleanup test_blueprint.py to use test fixtures
2017-05-23 17:14:57 -07:00
Randy Liou c03a82713a Cleanup test_blueprint.py to use test fixtures
Modify several tests to use the app and client test fixtures.
2017-05-23 16:42:14 -07:00
Randy Liou 3fce4898f8 Add test for Blueprint app-wide url processing
The test add coverage for methods: Blueprint.app_url_defaults, and
Blueprint.app_url_preprocessing. This PR increases the coverage of
blueprint module by 2%.
2017-05-23 16:26:53 -07:00
Christian Stade-Schuldt 5b0b9717da 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
Randy Liou d8d712a0de 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 a690ae27a3 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
Randy Liou 7ce01ab9b4 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 e706b5e544 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 136dbf7de0 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
Randy Liou 9fddecd4d9 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
Randy Liou 954b7ef7bb Enhance code coverage for Blueprint.endpoint
Add basic test for the endpoint decorator for the Blueprint object.
2016-06-03 16:02:45 -07:00
Reuven 4dc2ef19ea Use pytest.raises() instead of try/catch with asser 0
This is somehow more readable, and enable using the features of pytest's ExeptionInfo (such as errisinstance).
2016-03-04 13:30:40 +02:00
Parkayun 33534bb4a9 Happy New Year 2015 2015-01-02 11:35:00 +09:00
Markus Unterwaditzer c6795eb626 Remove useless unittest imports 2014-09-21 16:47:38 +02:00
Markus Unterwaditzer 861aa0db1f Init global test_apps explicitly 2014-09-11 22:09:51 +02:00
Markus Unterwaditzer af4cb0ff2b Remove flask superclass 2014-09-11 22:09:51 +02:00
Markus Unterwaditzer af41dbe0c4 Remove useless classes 2014-09-11 22:09:51 +02:00
Markus Unterwaditzer 5da2c00419 Rewrite assertion methods 2014-09-11 22:09:51 +02:00
Markus Unterwaditzer 8fa5e32d9a Tests pass now. 2014-09-11 22:09:50 +02:00
Markus Unterwaditzer 961db8ad72 Made tests recognizable 2014-09-11 22:09:50 +02:00