Description of problem:
Our tests use
import unittest2 as unittest
and new versions of python provides only unittest which is compatible with unittest2 but there's no alias that would make our lives easier.
Version-Release number of selected component (if applicable):
... import unittest2 as unittest
... except ImportError:
... import unittest
<module 'unittest' from '/usr/lib64/python2.7/unittest/__init__.pyc'>
What's bad about this approach?
(In reply to Robert Kuska from comment #1)
> >>> try:
> ... import unittest2 as unittest
> ... except ImportError:
> ... import unittest
> >>> unittest
> <module 'unittest' from '/usr/lib64/python2.7/unittest/__init__.pyc'>
> What's bad about this approach?
I guess that people just don't expect their code to break when we say that "python" provides "python-unittest2". I'll fix this by providing a fake "unittest2" module in python, that will just provide everything from unittest.
python-2.7.8-6.fc21 has been submitted as an update for Fedora 21.
This somehow breaks python-boto's unit tests in rawhide when they use the try-except construct above.
ERROR: Failure: ValueError (no such test method in <class 'tests.unit.auth.test_query.TestQueryAuthHandler'>: runTest)
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/loader.py", line 519, in makeTest
return self._makeTest(obj, parent)
File "/usr/lib/python2.7/site-packages/nose/loader.py", line 578, in _makeTest
File "/usr/lib/python2.7/site-packages/nose/case.py", line 345, in __init__
self.inst = self.cls()
File "/usr/lib64/python2.7/unittest2/case.py", line 227, in __init__
ValueError: no such test method in <class 'tests.unit.auth.test_query.TestQueryAuthHandler'>: runTest
I haven't been able to figure out exactly how that manages to break things yet, but at first glance I suspect it has something to do with nose's conditional imports. Oddly enough, replacing the try-except import code with a simple "import unittests" statement makes the tests start working, despite the fact that python-unittest2 is not installed.
In case it helps, the full build log is here:
...and the failing test suite's imports are here:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python-2.7.8-6.fc21'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
Since this change broke boto's test-suite and fedmsg unittests, I'll revert this change. I think that the amount of broken code is much higher than just these two examples, but most of the affected packages just haven't been rebuilt.
As means to overcome this, I suggest using the approach from comment 1. Thanks for understanding.
python-2.7.8-7.fc21 has been submitted as an update for Fedora 21.
Reverted. I'm starting to think we should unretire python-unittest2 and upgrade it to latest upstream. It seems to have been revived (4 new versions released in past month, latest being 0.8.0 ) and will probably have a different lifecycle than Python core - therefore it again makes sense to have it as a separate package.
I'm going to unretire it ASAP, I'll note it in this bug when it's done.
Right, unittest2 is a living backport of new stdlib unittest features. It was just idle for a long while, as we hadn't added anything particularly interesting since 2.7/3.2 (until subtest support in 3.4), and Michael didn't have a lot of time for upstream work.
Robert Collins now has an agreement with HP to spend work time on stdlib testing capabilities, which seems to have rekindled activity, including updating unittest2 to be on par with the Python 3.4 standard library (including subtest support!: https://hg.python.org/unittest2/file/bfdcdc6bdb89/unittest2/case.py#l503).
python-unittest2-0.8.0-1.fc21 has been submitted as an update for Fedora 21.
Hmm, it seems that the python-unittest2 package had to be blocked, since if the package is retired more than two weeks, it obviously requires a new review . I'll go on and do it (yes, it's very frustrating).
python-unittest2-0.8.0-2.fc21 has been pushed to the Fedora 21 testing repository.
python-2.7.8-7.fc21 has been pushed to the Fedora 21 stable repository. If problems still persist, please make note of it in this bug report.
python-unittest2-0.8.0-2.fc21 has been pushed to the Fedora 21 stable repository.
Unretiring python-unittest2 was the right approach, and that is all done now... but there is only piece missing. python still provides python-unittest2, so even if a package requires python-unittest2 yum will just ignore it since it sees it as provided by python.
diff --git a/python.spec b/python.spec
index b019a26..4ab28da 100644
@@ -928,8 +928,6 @@ Obsoletes: python-ctypes < 1.0.1
Provides: python-ctypes = 1.0.1
Obsoletes: python-hashlib < 20081120
Provides: python-hashlib = 20081120
-Obsoletes: python-unittest2 < 0.5.1-9
-Provides: python-unittest2 = 0.5.1-9
Obsoletes: python-uuid < 1.31
Provides: python-uuid = 1.31
# obsolete, not provide PyXML as proposed in feature