classification
Title: "python -m unittest " does not run any tests
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.4, Python 2.6, Python 2.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: exarkun, ezio.melotti, michael.foord
Priority: normal Keywords:

Created on 2009-07-18 14:51 by exarkun, last changed 2011-04-10 09:30 by ezio.melotti. This issue is now closed.

Messages (4)
msg90681 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2009-07-18 14:51
exarkun@boson:~$ cat > test_foo.py
from unittest import TestCase

class SomeTests(TestCase):
    def test_foo(self):
        pass
exarkun@boson:~$ python -m unittest test_foo

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
exarkun@boson:~$ python -m unittest test_foo.SomeTests
Traceback (most recent call last):
  File "/usr/lib/python2.5/runpy.py", line 95, in run_module
    filename, loader, alter_sys)
  File "/usr/lib/python2.5/runpy.py", line 52, in _run_module_code
    mod_name, mod_fname, mod_loader)
  File "/usr/lib/python2.5/runpy.py", line 32, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.5/unittest.py", line 816, in <module>
    main(module=None)
  File "/usr/lib/python2.5/unittest.py", line 767, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python2.5/unittest.py", line 794, in parseArgs
    self.createTests()
  File "/usr/lib/python2.5/unittest.py", line 800, in createTests
    self.module)
  File "/usr/lib/python2.5/unittest.py", line 565, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.5/unittest.py", line 553, in loadTestsFromName
    test = obj()
  File "/usr/lib/python2.5/unittest.py", line 209, in __init__
    (self.__class__, methodName)
ValueError: no such test method in <class 'test_foo.SomeTests'>: runTest
exarkun@boson:~$ python -m unittest test_foo.SomeTests.test_foo
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
exarkun@boson:~$ 

I don't really know what's happening in the middle case.  The first case
seems to fail because the test loader goes around looking for subclasses
of __main__.TestCase.  It only finds subclasses of unittest.TestCase,
though, which it rejects.
msg90728 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-07-20 11:54
I can duplicate the problem - I wonder if this has to do with the
refactoring into a package? Anyway, thanks for catching this.
msg90729 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-07-20 12:07
Ha - no I can't reproduce it on trunk.

The python -m features are new in trunk and neither documented nor
working in 2.4-2.6.
msg90730 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-07-20 12:22
This isn't a bug - the command line message if you run "python -m
unittest" on Python 2.4-2.6 is just confusing. It has never worked.
History
Date User Action Args
2011-04-10 09:35:21georg.brandllinkissue11819 superseder
2011-04-10 09:30:46ezio.melottisetnosy: + ezio.melotti
2009-07-20 12:22:38michael.foordsetstatus: open -> closed
resolution: rejected
messages: + msg90730
2009-07-20 12:07:42michael.foordsetmessages: + msg90729
2009-07-20 11:54:49michael.foordsetmessages: + msg90728
2009-07-20 11:25:18georg.brandlsetassignee: michael.foord

nosy: + michael.foord
2009-07-18 14:51:25exarkuncreate