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.
IIRC, mock and unittest2 are from the same author, so I'd guess it's intentional.
(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 ;).
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).
(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.
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.
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 :/
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.
Old version removed. Please reopen if it still happens.