File tree Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,8 @@ def _register(state):
23
23
state .app .modules [module .name ] = module
24
24
path = module .static_path
25
25
# XXX: backwards compatibility. This will go away in 1.0
26
- if path is None and module ._backwards_compat_static_path :
27
- path = module .static_path
28
- if path == app .static_path :
26
+ if module ._backwards_compat_static_path :
27
+ if path == state .app .static_path :
29
28
return
30
29
from warnings import warn
31
30
warn (DeprecationWarning ('With Flask 0.7 the static folder '
@@ -35,7 +34,7 @@ def _register(state):
35
34
'Pass ``static_path=\' static\' `` to the Module '
36
35
'constructor if you want to use static folders.\n '
37
36
'This backwards compatibility support will go away in '
38
- 'Flask 1.0' ), stacklevel = 3 )
37
+ 'Flask 1.0' ), stacklevel = 2 )
39
38
if path is None :
40
39
return
41
40
path = '/' + os .path .basename (path )
Original file line number Diff line number Diff line change @@ -828,6 +828,15 @@ def test_safe_access(self):
828
828
else :
829
829
assert 0 , 'expected exception'
830
830
831
+ def test_static_path_backwards_compat (self ):
832
+ with catch_warnings () as captured :
833
+ from modulecompat import app
834
+ rv = app .test_client ().get ('/test/static/hello.txt' )
835
+ assert rv .data .strip () == 'Hello World!'
836
+
837
+ # the warning for missing static_path
838
+ assert len (captured ) == 1
839
+
831
840
832
841
class SendfileTestCase (unittest .TestCase ):
833
842
Original file line number Diff line number Diff line change
1
+ from flask import Flask
2
+
3
+
4
+ app = Flask (__name__ )
5
+ from modulecompat .test import mod
6
+ app .register_module (mod , url_prefix = '/test' )
Original file line number Diff line number Diff line change
1
+ from flask import Module
2
+
3
+
4
+ mod = Module (__name__ )
Original file line number Diff line number Diff line change
1
+ Hello World!
You can’t perform that action at this time.
0 commit comments