unittest is broken

Bug #395362 reported by Xavier Gnata
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nose (Ubuntu)
New
Undecided
Unassigned
python-defaults (Ubuntu)
New
Undecided
Unassigned
python2.6 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Hi,

Bug 389942 is caused by this difference between -0ubuntu1 and -0ubuntu2 (jaunty and karmic):
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -798,8 +798,10 @@ Examples:
                                                in MyTestCase
 """
     def __init__(self, module='__main__', defaultTest=None,
- argv=None, testRunner=TextTestRunner,
+ argv=None, testRunner=None,
                  testLoader=defaultTestLoader):
+ if testRunner is None:
+ testRunner = TextTestRunner
         if type(module) == type(''):
             self.module = __import__(module)
             for part in module.split('.')[1:]:

This changes fully breaks python-nose this way:
nosetests
Traceback (most recent call last):
  File "/usr/bin/nosetests", line 8, in <module>
    load_entry_point('nose==0.10.4', 'console_scripts', 'nosetests')()
  File "/usr/lib/pymodules/python2.6/nose/core.py", line 219, in
__init__
    argv=argv, testRunner=testRunner, testLoader=testLoader)
  File "/usr/lib/python2.6/unittest.py", line 819, in __init__
    self.runTests()
  File "/usr/lib/pymodules/python2.6/nose/core.py", line 298, in
runTests
    result = self.testRunner.run(self.test)
TypeError: unbound method run() must be called with TextTestRunner
instance as first argument (got ContextSuite instance instead)

If you revert this patch, nosetests is working again.
What was the driver of this patch? Would it break something if you revert it?...as least it would fix python-nose.

Revision history for this message
Max Bowsher (maxb) wrote :

Hi Xavier,

As you note in your bug description, there is already a bug filed for this issue. Therefore, I'm marking this bug as a duplicate, and will open a python2.6 task on the parent bug.

I will not open a python-defaults task on the parent bug because I see no reason why python-defaults is involved.

Revision history for this message
Xavier Gnata (xavier-gnata-gmail) wrote : Re: [Bug 395362] Re: unittest is broken

> *** This bug is a duplicate of bug 389942 ***
> https://bugs.launchpad.net/bugs/389942
>
> Hi Xavier,
>
> As you note in your bug description, there is already a bug filed for
> this issue. Therefore, I'm marking this bug as a duplicate, and will
> open a python2.6 task on the parent bug.
>
> I will not open a python-defaults task on the parent bug because I see
> no reason why python-defaults is involved.
>
> ** This bug has been marked a duplicate of bug 389942
> python-nose is broken in Karmic alpha 2
>
>

Hi,

Well the point is that python2.6.2.tgz from python.org do not show this
patch on Lib/unittest.py. It reads:
def __init__(self, module='__main__', defaultTest=None,
                 argv=None, testRunner=TextTestRunner,
                 testLoader=defaultTestLoader):
        if type(module) == type(''):
            self.module = __import__(module)
            for part in module.split('.')[1:]:
                self.module = getattr(self.module, part)

Why is unittest.py patched by python2.6_2.6.2-0ubuntu2.diff this way?:

+--- Lib/unittest.py (.../tags/r262) (Revision 73476)
++++ Lib/unittest.py (.../branches/release26-maint) (Revision 73476)
+@@ -798,8 +798,10 @@
+ in MyTestCase
+ """
+ def __init__(self, module='__main__', defaultTest=None,
+- argv=None, testRunner=TextTestRunner,
++ argv=None, testRunner=None,
+ testLoader=defaultTestLoader):
++ if testRunner is None:
++ testRunner = TextTestRunner
+ if type(module) == type(''):
+ self.module = __import__(module)
+ for part in module.split('.')[1:]:

unittest.py comes from python2.6 that is why I have opened this bug
(but maybe it is not good practice. Please tell me).

Will this patch on unittest.py part of python2.6.3 ?
Should python-nose try to accomadate with this patch ?

Xavier

Revision history for this message
Max Bowsher (maxb) wrote :

> Why is unittest.py patched by python2.6_2.6.2-0ubuntu2.diff this way?

I advise reading the changelog and/or examining the package in more detail. You will see it is a change taken from upstream svn. Therefore...

> Will this patch on unittest.py part of python2.6.3 ?

Yes.

> unittest.py comes from python2.6 that is why I have opened this bug
> (but maybe it is not good practice. Please tell me).

Generally, one problem == one bug. Launchpad bugs can have multiple bugtasks applying to different packages.

> Should python-nose try to accomadate with this patch ?

Yes, see bug 389942 for more.

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.