Tests depend on unittest2

Bug #1183953 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Released
Wishlist
Unassigned

Bug Description

The dependency on unittest2 causes problems when trying to run the tests for Python 3 at package build time in Debian and Ubuntu. We don't have a python3-unittest2 package available. IIUC, upstream unittest2 doesn't support Python 3 anyway; that's available in a separate package called: https://pypi.python.org/pypi/unittest2py3k but that's not available in Debian.

Is the dependency on unittest2py3k really necessary for Python 3? Is it possible to conditionally import unittest2 only when running in Python 2?

Revision history for this message
Barry Warsaw (barry) wrote :

Oh, and related: LP: #1097061

(but I agree with the above that a dependency on Twisted for testing is suboptimal)

Revision history for this message
Florent (florent.x) wrote :

Well, I have nothing against removing this dependency, but I fail to integrate "unittest" from Python 3.3 and "setuptools" ...

This is the problematic line in "setup.py":

    'test_suite': 'unittest2.collector.collector'

Any idea ?
Thanks.

Changed in pyflakes:
importance: Undecided → Wishlist
Revision history for this message
Barry Warsaw (barry) wrote : Re: [Bug 1183953] Re: Tests depend on unittest2

On Jun 15, 2013, at 12:29 PM, Florent wrote:

>Well, I have nothing against removing this dependency, but I fail to
>integrate "unittest" from Python 3.3 and "setuptools" ...
>
>This is the problematic line in "setup.py":
>
> 'test_suite': 'unittest2.collector.collector'
>
>Any idea ?

Since all your tests live in the pyflakes.test subpackage, it should be enough
to just do this:

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup
    extra = {'scripts': ["bin/pyflakes"]}
else:
    if sys.version_info < (3,):
        extra = {'tests_require': ['unittest2'],
                 'test_suite': 'unittest2.collector'}
    else:
        ## extra = {'tests_require': ['unittest2py3k'],
        ## 'test_suite': 'unittest2.collector.collector'}
        extra = {'test_suite': 'pyflakes.test'}
    extra['entry_points'] = {
        'console_scripts': ['pyflakes = pyflakes.api:main'],
    }

After I changed all the imports from 'unittest2' to 'unittest', it all just
worked:

...
----------------------------------------------------------------------
Ran 544 tests in 0.467s

OK (skipped=33)

Revision history for this message
Florent (florent.x) wrote :

Thank you for this hint, Barry.

I dropped the test dependency for Python >= 2.7 (in revision 101).

Changed in pyflakes:
milestone: none → 0.7.x
status: New → Fix Committed
Florent (florent.x)
Changed in pyflakes:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.