aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElrond <elrond+mediagoblin.org@samba-tng.org>2013-04-25 13:53:19 +0200
committerElrond <elrond+mediagoblin.org@samba-tng.org>2013-04-25 14:31:29 +0200
commitd8919664244a9e1bae2c373252a9fdd14321a423 (patch)
treeb3c84e4f4d95476a6612b72961e2c81a7b9fb4cb
parent5ae0cbaa551ca1457bb9b84ccad72836db1bf5fc (diff)
downloadmediagoblin-d8919664244a9e1bae2c373252a9fdd14321a423.tar.lz
mediagoblin-d8919664244a9e1bae2c373252a9fdd14321a423.tar.xz
mediagoblin-d8919664244a9e1bae2c373252a9fdd14321a423.zip
Unit test for ReallyLazyProxy.
LazyProxy caches its value. So create a unit test for lazy_pass_to_ugettext to make sure its returned proxy actually gives a different translation when the locale is switched.
-rw-r--r--mediagoblin/tests/test_util.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_util.py b/mediagoblin/tests/test_util.py
index e4c04b7a..bc14f528 100644
--- a/mediagoblin/tests/test_util.py
+++ b/mediagoblin/tests/test_util.py
@@ -104,6 +104,28 @@ def test_locale_to_lower_lower():
assert translate.locale_to_lower_lower('en_us') == 'en-us'
+def test_gettext_lazy_proxy():
+ from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
+ from mediagoblin.tools.translate import pass_to_ugettext, set_thread_locale
+ proxy = _(u"Password")
+ orig = u"Password"
+
+ set_thread_locale("es")
+ p1 = unicode(proxy)
+ p1_should = pass_to_ugettext(orig)
+ assert p1_should != orig, "Test useless, string not translated"
+ assert p1 == p1_should
+
+ set_thread_locale("sv")
+ p2 = unicode(proxy)
+ p2_should = pass_to_ugettext(orig)
+ assert p2_should != orig, "Test broken, string not translated"
+ assert p2 == p2_should
+
+ assert p1_should != p2_should, "Test broken, same translated string"
+ assert p1 != p2
+
+
def test_html_cleaner():
# Remove images
result = text.clean_html(