Skip to content
Myr

Cherry-pick 7ba35c4 from master (support pathlib.Path for static_folder)

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

authored by Joshua Bronson · committed by Joshua Bronson · parent 88c9c68 · Browse files · 3 files+22 added−1 removed
This commit

State

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

Diff stats

3 files+22 added−1 removed

  • tests:+10 added−0 removed
  • other:+12 added−1 removed

3 files+22 added−1 removed

modified:src/flask/helpers.py+1 added-1 removed
999 unmodified lines
10001001 @static_folder.setter1002 def static_folder(self, value):1003 if value is not None:1004 value = value.rstrip("/\\")1004 value = os.fspath(value).rstrip(r"\/")1005 self._static_folder = value10061007 @property1008 def static_url_path(self):
147 unmodified lines
modified:tests/test_basic.py+10 added
1423 unmodified lines
1424 assert rv.status_code == 2001425 rv.close()142614271428@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python >= 3.6")1429def test_static_folder_with_pathlib_path(app):1430 from pathlib import Path14311432 app = flask.Flask(__name__, static_folder=Path("static"))1433 rv = app.test_client().open("/static/index.html", method="GET")1434 assert rv.status_code == 2001435 rv.close()143614371438def test_static_folder_with_ending_slash():1439 app = flask.Flask(__name__, static_folder="static/")14401441 @app.route("/<path:path>")
547 unmodified lines
modified:CHANGES.rst+11 added
1.. currentmodule:: flask2345Version 1.1.x6-------------78Not yet released.910- Officially support passing a :class:`pathlib.Path` for11 ``static_folder`` which stopped working in 1.1.2. :pr:`3579`121314Version 1.1.215-------------1617Released 2020-04-03
1012 unmodified lines