|
2 | 2 | from __future__ import with_statement
|
3 | 3 |
|
4 | 4 | from datetime import datetime, timedelta
|
5 |
| -from threading import Semaphore, Thread |
6 | 5 |
|
7 | 6 | import flask
|
8 | 7 |
|
@@ -107,60 +106,3 @@ def test_refreshing():
|
107 | 106 | app.config['BABEL_DEFAULT_TIMEZONE'] = 'Europe/Vienna'
|
108 | 107 | babel.refresh()
|
109 | 108 | assert babel.format_datetime(d) == 'Apr 12, 2010, 3:46:00 PM'
|
110 |
| - |
111 |
| - |
112 |
| -def test_force_locale(): |
113 |
| - app = flask.Flask(__name__) |
114 |
| - b = babel.Babel(app) |
115 |
| - |
116 |
| - @b.localeselector |
117 |
| - def select_locale(): |
118 |
| - return 'de_DE' |
119 |
| - |
120 |
| - with app.test_request_context(): |
121 |
| - assert str(babel.get_locale()) == 'de_DE' |
122 |
| - with babel.force_locale('en_US'): |
123 |
| - assert str(babel.get_locale()) == 'en_US' |
124 |
| - assert str(babel.get_locale()) == 'de_DE' |
125 |
| - |
126 |
| - |
127 |
| -def test_force_locale_with_threading(): |
128 |
| - app = flask.Flask(__name__) |
129 |
| - b = babel.Babel(app) |
130 |
| - |
131 |
| - @b.localeselector |
132 |
| - def select_locale(): |
133 |
| - return 'de_DE' |
134 |
| - |
135 |
| - semaphore = Semaphore(value=0) |
136 |
| - |
137 |
| - def first_request(): |
138 |
| - with app.test_request_context(): |
139 |
| - with babel.force_locale('en_US'): |
140 |
| - assert str(babel.get_locale()) == 'en_US' |
141 |
| - semaphore.acquire() |
142 |
| - |
143 |
| - thread = Thread(target=first_request) |
144 |
| - thread.start() |
145 |
| - |
146 |
| - try: |
147 |
| - with app.test_request_context(): |
148 |
| - assert str(babel.get_locale()) == 'de_DE' |
149 |
| - finally: |
150 |
| - semaphore.release() |
151 |
| - thread.join() |
152 |
| - |
153 |
| - |
154 |
| -def test_refresh_during_force_locale(): |
155 |
| - app = flask.Flask(__name__) |
156 |
| - b = babel.Babel(app) |
157 |
| - |
158 |
| - @b.localeselector |
159 |
| - def select_locale(): |
160 |
| - return 'de_DE' |
161 |
| - |
162 |
| - with app.test_request_context(): |
163 |
| - with babel.force_locale('en_US'): |
164 |
| - assert str(babel.get_locale()) == 'en_US' |
165 |
| - babel.refresh() |
166 |
| - assert str(babel.get_locale()) == 'en_US' |
0 commit comments