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


Groups > comp.lang.python > #21857

Unittest2 on python 2.6

Date 2012-03-18 13:31 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
Subject Unittest2 on python 2.6
Newsgroups comp.lang.python
Message-ID <mailman.779.1332077531.3037.python-list@python.org> (permalink)

Show all headers | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web