Skip to content

Commit dad9165

Browse files
committed
Explicit app factory test.
1 parent 38f15cd commit dad9165

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_app_factory.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import flask
2+
import flask_babel as babel
3+
4+
5+
def test_app_factory():
6+
b = babel.Babel()
7+
8+
def locale_selector():
9+
return 'de_DE'
10+
11+
def create_app():
12+
app_ = flask.Flask(__name__)
13+
b.init_app(
14+
app_,
15+
default_locale='en_US',
16+
locale_selector=locale_selector
17+
)
18+
return app_
19+
20+
app = create_app()
21+
with app.test_request_context():
22+
assert str(babel.get_locale()) == 'de_DE'
23+
assert babel.gettext(u'Hello %(name)s!', name='Peter') == \
24+
'Hallo Peter!'

0 commit comments

Comments
 (0)