Bug 1161166 - Please provide unittest2 -> unittest alias
Summary: Please provide unittest2 -> unittest alias
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python
Version: 21
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Bohuslav "Slavek" Kabrda
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-06 14:50 UTC by Richard Marko
Modified: 2016-02-01 02:23 UTC (History)
12 users (show)

Fixed In Version: python-unittest2-0.8.0-2.fc21
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-12-06 10:11:34 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Richard Marko 2014-11-06 14:50:31 UTC
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):
python-2.7.8-5.fc21.x86_64

Comment 1 Robert Kuska 2014-11-07 06:59:40 UTC
>>> 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?

Comment 2 Bohuslav "Slavek" Kabrda 2014-11-07 07:10:00 UTC
(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.

Comment 3 Fedora Update System 2014-11-07 11:20:02 UTC
python-2.7.8-6.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/python-2.7.8-6.fc21

Comment 4 Garrett Holmstrom 2014-11-08 01:03:39 UTC
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
    return MethodTestCase(obj)
  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__
    (self.__class__, methodName))
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:

https://kojipkgs.fedoraproject.org//work/tasks/6738/8066738/build.log

...and the failing test suite's imports are here:

https://github.com/boto/boto/blob/develop/tests/compat.py

Comment 5 Fedora Update System 2014-11-10 06:45:16 UTC
Package python-2.7.8-6.fc21:
* 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:
https://admin.fedoraproject.org/updates/FEDORA-2014-14645/python-2.7.8-6.fc21
then log in and leave karma (feedback).

Comment 6 Bohuslav "Slavek" Kabrda 2014-11-10 08:03:49 UTC
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.

Comment 7 Fedora Update System 2014-11-10 10:15:43 UTC
python-2.7.8-7.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/python-2.7.8-7.fc21

Comment 8 Bohuslav "Slavek" Kabrda 2014-11-10 10:19:03 UTC
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 [1]) 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.

[1] https://pypi.python.org/pypi/unittest2/0.8.0

Comment 9 Nick Coghlan 2014-11-10 12:26:30 UTC
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).

Comment 10 Fedora Update System 2014-11-10 15:43:48 UTC
python-unittest2-0.8.0-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/python-unittest2-0.8.0-1.fc21

Comment 11 Bohuslav "Slavek" Kabrda 2014-11-11 06:51:50 UTC
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 [1]. I'll go on and do it (yes, it's very frustrating).

[1] https://fedorahosted.org/rel-eng/ticket/6041#comment:3

Comment 12 Fedora Update System 2014-11-15 09:10:18 UTC
python-unittest2-0.8.0-2.fc21 has been pushed to the Fedora 21 testing repository.

Comment 13 Fedora Update System 2014-11-15 09:11:03 UTC
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.

Comment 14 Fedora Update System 2014-12-06 10:11:34 UTC
python-unittest2-0.8.0-2.fc21 has been pushed to the Fedora 21 stable repository.

Comment 15 Dan Callaghan 2015-04-09 00:10:27 UTC
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
--- a/python.spec
+++ b/python.spec
@@ -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


Note You need to log in before you can comment on or make changes to this bug.