diff options
author | Jason Madden <jamadden@gmail.com> | 2017-12-17 09:26:25 -0600 |
---|---|---|
committer | Jason Madden <jamadden@gmail.com> | 2017-12-17 09:26:25 -0600 |
commit | ac16be8fed6cc840ad0f3244c883c8b7a672f643 (patch) | |
tree | f92f1b42c841c95a05a859a71ab39555ac582977 /src/zope/i18n/tests | |
parent | f7c832709a6026ae423b4b9dc3c47d2c75f72f28 (diff) | |
download | zope-i18n-ac16be8fed6cc840ad0f3244c883c8b7a672f643.tar.gz |
Remove testiii18naware.py because it didn't have any actual tests and was only used in one module, testi18nawareobject.py. This improves coverage.
Diffstat (limited to 'src/zope/i18n/tests')
-rw-r--r-- | src/zope/i18n/tests/testi18nawareobject.py | 36 | ||||
-rw-r--r-- | src/zope/i18n/tests/testii18naware.py | 41 |
2 files changed, 24 insertions, 53 deletions
diff --git a/src/zope/i18n/tests/testi18nawareobject.py b/src/zope/i18n/tests/testi18nawareobject.py index 8d52e43..21a61f4 100644 --- a/src/zope/i18n/tests/testi18nawareobject.py +++ b/src/zope/i18n/tests/testi18nawareobject.py @@ -16,7 +16,6 @@ import unittest from zope.i18n.interfaces import II18nAware -from zope.i18n.tests.testii18naware import TestII18nAware from zope.interface import implementer @@ -55,8 +54,29 @@ class I18nAwareContentObject(object): # ############################################################ +class AbstractTestII18nAwareMixin(object): -class TestI18nAwareObject(TestII18nAware): + def setUp(self): + self.object = self._createObject() + self.object.setDefaultLanguage('fr') + + def _createObject(self): + # Should create an object that has lt, en and fr as available + # languages + raise NotImplementedError() + + def testGetDefaultLanguage(self): + self.assertEqual(self.object.getDefaultLanguage(), 'fr') + + def testSetDefaultLanguage(self): + self.object.setDefaultLanguage('lt') + self.assertEqual(self.object.getDefaultLanguage(), 'lt') + + def testGetAvailableLanguages(self): + self.assertEqual(sorted(self.object.getAvailableLanguages()), ['en', 'fr', 'lt']) + + +class TestI18nAwareObject(AbstractTestII18nAwareMixin, unittest.TestCase): def _createObject(self): object = I18nAwareContentObject() @@ -71,17 +91,9 @@ class TestI18nAwareObject(TestII18nAware): def testGetContent(self): self.assertEqual(self.object.getContent('en'), 'English') - self.assertRaises(KeyError, self.object.getContent, 'es') + with self.assertRaises(KeyError): + self.object.getContent('es') def testQueryContent(self): self.assertEqual(self.object.queryContent('en'), 'English') self.assertEqual(self.object.queryContent('es', 'N/A'), 'N/A') - - -def test_suite(): - loader = unittest.TestLoader() - return loader.loadTestsFromTestCase(TestI18nAwareObject) - - -if __name__ == '__main__': - unittest.TextTestRunner().run(test_suite()) diff --git a/src/zope/i18n/tests/testii18naware.py b/src/zope/i18n/tests/testii18naware.py deleted file mode 100644 index cc37ef8..0000000 --- a/src/zope/i18n/tests/testii18naware.py +++ /dev/null @@ -1,41 +0,0 @@ -############################################################################## -# -# Copyright (c) 2001, 2002 Zope Foundation and Contributors. -# All Rights Reserved. -# -# This software is subject to the provisions of the Zope Public License, -# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. -# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED -# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS -# FOR A PARTICULAR PURPOSE. -# -############################################################################## -"""This is a test for the II18nAware interface. -""" -import unittest - -class TestII18nAware(unittest.TestCase): - - def setUp(self): - self.object = self._createObject() - self.object.setDefaultLanguage('fr') - - def _createObject(self): - # Should create an object that has lt, en and fr as available - # languages - pass - - def testGetDefaultLanguage(self): - self.assertEqual(self.object.getDefaultLanguage(), 'fr') - - def testSetDefaultLanguage(self): - self.object.setDefaultLanguage('lt') - self.assertEqual(self.object.getDefaultLanguage(), 'lt') - - def testGetAvailableLanguages(self): - self.assertEqual(sorted(self.object.getAvailableLanguages()), ['en', 'fr', 'lt']) - - -def test_suite(): - return unittest.TestSuite() # Deliberatly empty |