mirror of https://github.com/pallets/flask.git
Restore support for using pathlib.Path for static_folder.
* No longer causes AttributeError: 'PosixPath' object has no
attribute 'rstrip'.
* This was broken by e6178fe489
which was released in 1.1.2.
* Add a regression test that now passes.
See #3557.
This commit is contained in:
parent
b82cca7283
commit
7ba35c4d4f
|
@ -29,6 +29,15 @@ Unreleased
|
|||
argument can be passed. :issue:`3553`
|
||||
|
||||
|
||||
Version 1.1.x
|
||||
-------------
|
||||
|
||||
Not yet released.
|
||||
|
||||
- Officially support passing a :class:`pathlib.Path` for
|
||||
``static_folder`` which stopped working in 1.1.2. :pr:`3579`
|
||||
|
||||
|
||||
Version 1.1.2
|
||||
-------------
|
||||
|
||||
|
|
|
@ -980,7 +980,7 @@ class _PackageBoundObject:
|
|||
@static_folder.setter
|
||||
def static_folder(self, value):
|
||||
if value is not None:
|
||||
value = value.rstrip("/\\")
|
||||
value = os.fspath(value).rstrip(r"\/")
|
||||
self._static_folder = value
|
||||
|
||||
@property
|
||||
|
|
|
@ -1406,6 +1406,16 @@ def test_static_url_empty_path_default(app):
|
|||
rv.close()
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python >= 3.6")
|
||||
def test_static_folder_with_pathlib_path(app):
|
||||
from pathlib import Path
|
||||
|
||||
app = flask.Flask(__name__, static_folder=Path("static"))
|
||||
rv = app.test_client().open("/static/index.html", method="GET")
|
||||
assert rv.status_code == 200
|
||||
rv.close()
|
||||
|
||||
|
||||
def test_static_folder_with_ending_slash():
|
||||
app = flask.Flask(__name__, static_folder="static/")
|
||||
|
||||
|
|
Loading…
Reference in New Issue