aboutsummaryrefslogtreecommitdiffstats
path: root/tests/testcompat.py
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2013-08-13 18:51:32 +0200
committerMartin Vilcans <martin@librador.com>2013-08-13 18:51:32 +0200
commitdf008aca56897bbb96272a730fe259d0e9b98996 (patch)
tree6ef9194a5f39ad160240283484c4e573aebecdce /tests/testcompat.py
parent121dd5374458b38b2ab2a7e2acf30f5256a8d251 (diff)
downloadscreenplain-df008aca56897bbb96272a730fe259d0e9b98996.tar.gz
Use unittest2 if available but don't require it.
The features of unittest2 are already in Python >=2.7.
Diffstat (limited to 'tests/testcompat.py')
-rw-r--r--tests/testcompat.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/testcompat.py b/tests/testcompat.py
new file mode 100644
index 0000000..e0d0cba
--- /dev/null
+++ b/tests/testcompat.py
@@ -0,0 +1,17 @@
+# Copyright (c) 2011 Martin Vilcans
+# Licensed under the MIT license:
+# http://www.opensource.org/licenses/mit-license.php
+
+"""Provides compatibility between Python 2 and 3.
+
+In Python 2 we use the unittest2 module.
+The functionality of that module is already in Python 3,
+so we don't depend on it.
+This module exports the TestCase class from whatever unittest library we have.
+
+"""
+
+try:
+ from unittest2 import TestCase
+except ImportError:
+ from unittest import TestCase