Skip to content

Commit

Permalink
Tests for #107.
Browse files Browse the repository at this point in the history
  • Loading branch information
TkTech committed Jan 16, 2023
1 parent 9d12cc9 commit f17b04b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
10 changes: 6 additions & 4 deletions tests/test_gettext.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement

import flask

import flask_babel as babel
from flask_babel import gettext, lazy_gettext, lazy_ngettext, ngettext, \
from flask_babel import (
gettext,
lazy_gettext,
lazy_ngettext,
ngettext,
get_babel
)


def test_basics():
Expand Down
1 change: 0 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement

import pickle
Expand Down
22 changes: 22 additions & 0 deletions tests/test_multiple_apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import flask
import flask_babel as babel


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

app1 = flask.Flask(__name__)
b.init_app(app1, default_locale='de_DE')

app2 = flask.Flask(__name__)
b.init_app(app2, default_locale='en_US')

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

with app2.test_request_context():
assert babel.get_locale() == 'en_US'
assert babel.gettext(u'Hello %(name)s!', name='Peter') == \
'Hello Peter!'

0 comments on commit f17b04b

Please sign in to comment.