Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21857 > unrolled thread

Unittest2 on python 2.6

Started byAndrea Crotti <andrea.crotti.0@gmail.com>
First post2012-03-18 13:31 +0000
Last post2012-03-18 13:31 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Unittest2 on python 2.6 Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-03-18 13:31 +0000

#21857 — Unittest2 on python 2.6

FromAndrea Crotti <andrea.crotti.0@gmail.com>
Date2012-03-18 13:31 +0000
SubjectUnittest2 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?

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web