Unittest2 on python 2.6

Discussion in 'Python' started by Andrea Crotti, Mar 18, 2012.

  1. 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?
    Andrea Crotti, Mar 18, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    722
  2. Paul Moore
    Replies:
    0
    Views:
    594
    Paul Moore
    Mar 1, 2008
  3. Martin v. Löwis
    Replies:
    0
    Views:
    633
    Martin v. Löwis
    Mar 1, 2008
  4. Senthil Kumaran
    Replies:
    0
    Views:
    555
    Senthil Kumaran
    Jan 17, 2011
  5. Daniel Laird

    Help with unittest2

    Daniel Laird, Dec 13, 2012, in forum: Python
    Replies:
    7
    Views:
    135
    Terry Reedy
    Dec 13, 2012
Loading...

Share This Page