def test_switch_locale(self): bundle = Bundle(['tests/main.ftl'], default_locale='en') self.assertEqual(bundle.format('simple'), "Simple") activate('tr') self.assertEqual(bundle.format('simple'), "Basit") deactivate() self.assertEqual(bundle.format('simple'), "Simple")
def test_require_activate_after_activate(self): bundle = Bundle(['tests/main.ftl'], default_locale='en', require_activate=True) activate('en') self.assertEqual(bundle.format('simple'), 'Simple') deactivate() self.assertRaises(NoLocaleSet, bundle.format, 'simple')
def test_lazy(self): bundle = Bundle(['tests/main.ftl'], default_locale='en') l = bundle.format_lazy('simple') self.assertEqual(force_text(l), 'Simple') activate('fr-FR') self.assertEqual(force_text(l), 'Facile') deactivate() self.assertEqual(force_text(l), 'Simple')
def test_number_formatting(self): bundle = Bundle(['tests/main.ftl'], default_locale='en') self.assertEqual(bundle.format('with-number-argument', {'points': 1234567}), 'Score: \u20681,234,567\u2069') activate('fr-FR') self.assertEqual(bundle.format('with-number-argument', {'points': 1234567}), 'Points: \u20681\u202f234\u202f567\u2069') deactivate() self.assertEqual(bundle.format('with-number-argument', {'points': 1234567}), 'Score: \u20681,234,567\u2069')
def setUp(self): super(TestBase, self).setUp() deactivate()