Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 450620 - dev-python/mock: uses unittest2 in py2.7
Summary: dev-python/mock: uses unittest2 in py2.7
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL: http://code.google.com/p/mock/issues/...
Whiteboard:
Keywords:
Depends on:
Blocks: 450616
  Show dependency tree
 
Reported: 2013-01-06 18:45 UTC by Michał Górny
Modified: 2020-03-28 08:38 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-01-06 18:45:48 UTC
info = sys.version_info
if info[:3] >= (3, 2, 0):
    # for Python 3.2 ordinary unittest is fine
    import unittest as unittest2
else:
    import unittest2

Please investigate if it's just a version check mistake or 2.7 is not capable of something.
Comment 1 Dirkjan Ochtman gentoo-dev 2013-01-06 19:22:38 UTC
IIRC, mock and unittest2 are from the same author, so I'd guess it's intentional.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-01-06 19:31:49 UTC
(In reply to comment #1)
> IIRC, mock and unittest2 are from the same author, so I'd guess it's
> intentional.

I'll start investigating myself once I check all packages depending on unittest2 ;).
Comment 3 Mike Gilbert gentoo-dev 2013-01-07 05:59:03 UTC
It looks like setup.py for mock makes use of a unittest2-specific module. This is actually enough to make me rethink my stance on this; we should just install unittest2 for all python versions.

Here's the description from the docs.

http://pypi.python.org/pypi/unittest2#differences

unittest2 includes a very basic setuptools compatible test collector. Specify test_suite = 'unittest2.collector' in your setup.py. This starts test discovery with the default parameters from the directory containing setup.py, so it is perhaps most useful as an example (see unittest2/collector.py).
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-01-07 08:50:05 UTC
(In reply to comment #3)
> It looks like setup.py for mock makes use of a unittest2-specific module.
> This is actually enough to make me rethink my stance on this; we should just
> install unittest2 for all python versions.
> 
> Here's the description from the docs.
> 
> http://pypi.python.org/pypi/unittest2#differences
> 
> unittest2 includes a very basic setuptools compatible test collector.
> Specify test_suite = 'unittest2.collector' in your setup.py. This starts
> test discovery with the default parameters from the directory containing
> setup.py, so it is perhaps most useful as an example (see
> unittest2/collector.py).

So, as far as I can tell, the unittest2.discover is the only difference between the two, with unittest providing all the facilities necessary do the discovery.

To be honest, I really dislike installing and using whole unittest2 for those three lines of code but I guess we can't do anything much better.

Well, unless we assumed packages should not use anything else from unittest2 and instead installed own our wrapper using 'unittest' facilities.
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-01-07 22:09:41 UTC
It seems that tests do fine with py2.7's unittest.

As for the test discovery, I wonder if we should really pull in unittest2 for that. I wonder if we can't just do it by hand or handle it somehow else.

For python2.7, just doing:

  $ python -m unittest discover

suffices.
Comment 6 Pacho Ramos gentoo-dev 2013-09-28 12:26:48 UTC
Maybe committing the check fix:
https://code.google.com/p/mock/issues/detail?id=194

would be the path to go since upstream seems to not care :/
Comment 7 Virgil Dupras (RETIRED) gentoo-dev 2019-01-27 16:44:13 UTC
Upstream has dropped it in its repo: https://github.com/testing-cabal/mock/commit/89123d51895bdb828a7773228acc08b67d73255c

but the fix isn't part of a release yet.
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-03-28 08:38:09 UTC
Old version removed.  Please reopen if it still happens.