summaryrefslogtreecommitdiff
path: root/pystache/tests/common.py
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-04-08 20:52:38 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-04-08 20:52:38 -0700
commita8e390cb48a2f4757774c570c81e94fd0d2b676f (patch)
tree95d23030a6d1a1887d6f354d74c52ab09bfa09e3 /pystache/tests/common.py
parentf9bda3a5ce2725ca2e2b5a89fbd8a1b1e7642a90 (diff)
downloadpystache-a8e390cb48a2f4757774c570c81e94fd0d2b676f.tar.gz
All unit tests except for spec tests now work in both Python 2/3.
Diffstat (limited to 'pystache/tests/common.py')
-rw-r--r--pystache/tests/common.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/pystache/tests/common.py b/pystache/tests/common.py
index 446c0e5..8df6379 100644
--- a/pystache/tests/common.py
+++ b/pystache/tests/common.py
@@ -88,3 +88,28 @@ class AssertIsMixin:
# http://docs.python.org/library/unittest.html#unittest.TestCase.assertIsNone
def assertIs(self, first, second):
self.assertTrue(first is second, msg="%s is not %s" % (repr(first), repr(second)))
+
+
+class SetupDefaults(object):
+
+ """
+ Mix this class in to a unittest.TestCase for standard defaults.
+
+ This class allows for consistent test results across Python 2/3.
+
+ """
+
+ def setup_defaults(self):
+ self.original_decode_errors = defaults.DECODE_ERRORS
+ self.original_file_encoding = defaults.FILE_ENCODING
+ self.original_string_encoding = defaults.STRING_ENCODING
+
+ defaults.DECODE_ERRORS = 'strict'
+ defaults.FILE_ENCODING = 'ascii'
+ defaults.STRING_ENCODING = 'ascii'
+
+ def teardown_defaults(self):
+ defaults.DECODE_ERRORS = self.original_decode_errors
+ defaults.FILE_ENCODING = self.original_file_encoding
+ defaults.STRING_ENCODING = self.original_string_encoding
+