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


Groups > comp.lang.python > #21857

Unittest2 on python 2.6

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'suppose': 0.05; 'importerror:': 0.07; 'unittest': 0.07; 'python': 0.08; 'setup.py': 0.09; 'subject:python': 0.10; '2.6,': 0.16; 'ideas?': 0.16; 'try/except': 0.16; 'fine,': 0.23; 'received:74.125.82.174': 0.24; 'dance': 0.24; 'import': 0.27; 'bit': 0.28; 'message- id:@gmail.com': 0.31; 'header:User-Agent:1': 0.33; 'it?': 0.33; 'test': 0.34; 'file': 0.34; 'try:': 0.34; 'to:addr:python-list': 0.35; 'received:74.125.82': 0.36; 'to:name:python-list': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:192': 0.38; 'received:74.125': 0.38; 'should': 0.38; 'received:192.168.1': 0.39; 'except': 0.39; 'to:addr:python.org': 0.40
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=y8dELFN3imZ5rMDstNQL2uACkZJAMhodAssS1sXMIKE=; b=1CwBirAX55Tec0pqvKcCcQfIwnlhnO9dlltHsZIygzKXWj7ASzFq3060bNBoIHSBhE FrxYmZnHtmZt3+4Be8/Wkut/O5npvJL++9O9FJxdP9UpJ0qFlavwWBN8RQzlcEbs/ygK OZCyioQLWiWM1sg116WjqUOAoRoAq29zn2h+GIxQ/GmEJsBnWbBGEbb/XeSRSgdne+kO ytbfPHiLSMQFwJl7GkD1qtANf1h5otAtePIDT1HRNLlnJP4MEke4arvo+8C/o9kSMKrm Xs+Xnb9/PpdbXKBcTgKDPyDvWFb3QCoougLsA29sBtfh5NWSJIX9g+yApPlHuHfEFUm2 bXOA==
Date Sun, 18 Mar 2012 13:31:50 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120314 Thunderbird/11.0
MIME-Version 1.0
To python-list <python-list@python.org>
Subject Unittest2 on python 2.6
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.779.1332077531.3037.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332077531 news.xs4all.nl 6985 [2001:888:2000:d::a6]:58349
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21857

Show key headers only | 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