Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Unittest2 on python 2.6

 
 
Andrea Crotti
Guest
Posts: n/a
 
      03-18-2012
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?
 
Reply With Quote
 
 
 
Reply

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/python-list@python.org (was: UTF-8) skip@pobox.com Python 0 03-10-2007 02:50 PM



Advertisments