Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21857 > unrolled thread
| Started by | Andrea Crotti <andrea.crotti.0@gmail.com> |
|---|---|
| First post | 2012-03-18 13:31 +0000 |
| Last post | 2012-03-18 13:31 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Unittest2 on python 2.6 Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-03-18 13:31 +0000
| From | Andrea Crotti <andrea.crotti.0@gmail.com> |
|---|---|
| Date | 2012-03-18 13:31 +0000 |
| Subject | Unittest2 on python 2.6 |
| Message-ID | <mailman.779.1332077531.3037.python-list@python.org> |
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?
Back to top | Article view | comp.lang.python
csiph-web