Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Unittest2 on python 2.6

Thread Tools

Unittest2 on python 2.6

Andrea Crotti
Posts: n/a
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

if sys.version < '2.7':

and then in every test file

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?
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with unittest2 Daniel Laird Python 7 12-13-2012 08:50 PM
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 Senthil Kumaran Python 0 01-17-2011 10:31 AM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Martin v. L÷wis Python 0 03-01-2008 10:51 PM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Paul Moore Python 0 03-01-2008 10:39 PM
Searching comp.lang.python/ (was: UTF-8) Python 0 03-10-2007 02:50 PM