[Zope3-checkins] CVS: Zope3/src/zope/i18n/tests - test_globaltranslationservice.py:1.9 test_itranslationservice.py:1.4
Marius Gedminas
mgedmin@codeworks.lt
Fri, 11 Apr 2003 09:20:14 -0400
Update of /cvs-repository/Zope3/src/zope/i18n/tests
In directory cvs.zope.org:/tmp/cvs-serv29011/src/zope/i18n/tests
Modified Files:
test_globaltranslationservice.py test_itranslationservice.py
Log Message:
Changed ITranslationService to not require context when target_language is not
specified. Rationale: if language negotiation fails, target_language will
still be None, and we have to cope with that anyway.
Added a unit test and updated the three ITranslationService implementations.
=== Zope3/src/zope/i18n/tests/test_globaltranslationservice.py 1.8 => 1.9 ===
--- Zope3/src/zope/i18n/tests/test_globaltranslationservice.py:1.8 Thu Apr 3 15:20:34 2003
+++ Zope3/src/zope/i18n/tests/test_globaltranslationservice.py Fri Apr 11 09:20:13 2003
@@ -46,6 +46,11 @@
service.addCatalog(de_catalog)
return service
+ def testNoTargetLanguage(self):
+ # Having a fallback would interfere with this test
+ self._service.setLanguageFallbacks([])
+ TestITranslationService.testNoTargetLanguage(self)
+
def testSimpleNoTranslate(self):
translate = self._service.translate
raises = self.assertRaises
=== Zope3/src/zope/i18n/tests/test_itranslationservice.py 1.3 => 1.4 ===
--- Zope3/src/zope/i18n/tests/test_itranslationservice.py:1.3 Fri Mar 28 19:06:26 2003
+++ Zope3/src/zope/i18n/tests/test_itranslationservice.py Fri Apr 11 09:20:13 2003
@@ -89,7 +89,6 @@
eq(translate('default', 'short_greeting', context=context),
'Hallo!')
-
def testSimpleTranslate_bad_domain(self):
translate = self._service.translate
eq = self.assertEqual
@@ -99,7 +98,6 @@
default=42),
42)
-
def testDynamicTranslate(self):
translate = self._service.translate
eq = self.assertEqual
@@ -115,5 +113,19 @@
eq(translate('default', 'glorp_smurf_hmpf', target_language='en'),
None)
+ def testNoTargetLanguage(self):
+ translate = self._service.translate
+ eq = self.assertEqual
+ # Test that default is returned when no language can be negotiated
+ context = Environment(('xx', ))
+ eq(translate('default', 'short_greeting', context=context,
+ default=42),
+ 42)
+
+ # Test that default is returned when there's no destination language
+ eq(translate('default', 'short_greeting', default=42),
+ 42)
+
+
def test_suite():
- return unittest.TestSuite() # Deliberatly empty
+ return unittest.TestSuite() # Deliberately empty