Commits

Jonathan Ballet committed 9e608cc

Depend and install unittest2 on 'old' version of Python

'Old' versions are versions which don't feature the new unittest module,
available as a standalone module as unittest2.

Comments (0)

Files changed (3)

 
 [test]
 recipe = zc.recipe.testrunner
-eggs = keyring
+eggs = keyring [test]
 defaults = '--tests-pattern tests --exit-with-status'.split()
 working-directory = .
 
 
 distribute = 0.6.14
 setuptools = 0.6c11
+unittest2 = 0.5.1
 z3c.recipe.scripts = 1.0.1
 zc.buildout = 1.5.2
 zc.recipe.egg = 1.3.2

keyring/tests/test_backend.py

 import sys
 import tempfile
 import types
-import unittest
+
+try:
+    # Python < 2.7 annd Python >= 3.0 < 3.1
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 
 import keyring.backend
 from keyring.backend import PasswordSetError
     platforms = ["Many"],
     packages = ['keyring', 'keyring.tests', 'keyring.util',
                 'keyring.backends'],
+    extras_require={'test': []},
 )
 
+
 if sys.version_info >= (3,0):
     setup_params.update(
         use_2to3=True,
     )
 
+elif sys.version_info < (2, 7) or (
+    sys.version >= (3, 0) and sys.version < (3, 1)):
+    # Provide unittest2 for Python which doesn't contain the new unittest module
+    # (appears in Python 2.7 and Python 3.1)
+    setup_params.update(
+        tests_require=['unittest2'],
+    )
+    setup_params['extras_require']['test'].append('unittest2')
+
+
 if __name__ == '__main__':
     try:
         from setuptools import setup