Unittest2 on python 2.6

A

Andrea Crotti

Suppose we want to use the unittest from Python 2.7, but also want to
support Python 2.6,
what is the best way to do it?

The solution used now is to have in setup.py

if sys.version < '2.7':
tests_require.append('unittest2')

and then in every test file

try:
import unittest2 as unittest
except ImportError:
import unittest

and it should work just fine, but it's a bit verbose to have this
try/except dance everywhere..
Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,470
Messages
2,571,807
Members
48,797
Latest member
PeterSimpson
Top