Skip to content

Commit

Permalink
Explicit app factory test.
Browse files Browse the repository at this point in the history
  • Loading branch information
TkTech committed Oct 2, 2023
1 parent 38f15cd commit dad9165
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_app_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import flask
import flask_babel as babel


def test_app_factory():
b = babel.Babel()

def locale_selector():
return 'de_DE'

def create_app():
app_ = flask.Flask(__name__)
b.init_app(
app_,
default_locale='en_US',
locale_selector=locale_selector
)
return app_

app = create_app()
with app.test_request_context():
assert str(babel.get_locale()) == 'de_DE'
assert babel.gettext(u'Hello %(name)s!', name='Peter') == \
'Hallo Peter!'

0 comments on commit dad9165

Please sign in to comment.