diff options
Diffstat (limited to 'tests/base.py')
| -rw-r--r-- | tests/base.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/base.py b/tests/base.py new file mode 100644 index 0000000..92576c7 --- /dev/null +++ b/tests/base.py @@ -0,0 +1,58 @@ +# coding: utf8 +# Author: Rodrigo Bistolfi +# Date: 03/2013 + + +""" Base class for Nikola test cases """ + + +__all__ = ["BaseTestCase"] + + +import sys +import unittest + + +if sys.version_info < (2, 7): + + try: + import unittest2 + _unittest2 = True + except ImportError: + _unittest2 = False + + if _unittest2: + BaseTestCase = unittest2.TestCase + + else: + + class BaseTestCase(unittest.TestCase): + """ Base class for providing 2.6 compatibility """ + + def assertIs(self, first, second, msg=None): + self.assertTrue(first is second) + + def assertIsNot(self, first, second, msg=None): + self.assertTrue(first is not second) + + def assertIsNone(self, expr, msg=None): + self.assertTrue(expr is None) + + def assertIsNotNone(self, expr, msg=None): + self.assertTrue(expr is not None) + + def assertIn(self, first, second, msg=None): + self.assertTrue(first in second) + + def assertNotIn(self, first, second, msg=None): + self.assertTrue(first not in second) + + def assertIsInstance(self, obj, cls, msg=None): + self.assertTrue(isinstance(obj, cls)) + + def assertNotIsInstance(self, obj, cls, msg=None): + self.assertFalse(isinstance(obj, cls)) + + +else: + BaseTestCase = unittest.TestCase |
