From ac16be8fed6cc840ad0f3244c883c8b7a672f643 Mon Sep 17 00:00:00 2001 From: Jason Madden Date: Sun, 17 Dec 2017 09:26:25 -0600 Subject: Remove testiii18naware.py because it didn't have any actual tests and was only used in one module, testi18nawareobject.py. This improves coverage. --- src/zope/i18n/tests/testi18nawareobject.py | 36 +++++++++++++++++--------- src/zope/i18n/tests/testii18naware.py | 41 ------------------------------ 2 files changed, 24 insertions(+), 53 deletions(-) delete mode 100644 src/zope/i18n/tests/testii18naware.py (limited to 'src/zope/i18n') 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 -- cgit v1.2.1