[issue6514] "python -m unittest <testmodule>" does not run any tests
Jean-Paul Calderone
report at bugs.python.org
Sat Jul 18 16:51:26 CEST 2009
New submission from Jean-Paul Calderone <exarkun at divmod.com>:
exarkun at boson:~$ cat > test_foo.py
from unittest import TestCase
class SomeTests(TestCase):
def test_foo(self):
pass
exarkun at boson:~$ python -m unittest test_foo
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
exarkun at 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 at boson:~$ python -m unittest test_foo.SomeTests.test_foo
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
exarkun at 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.
----------
components: Library (Lib)
messages: 90681
nosy: exarkun
severity: normal
status: open
title: "python -m unittest <testmodule>" does not run any tests
type: behavior
versions: Python 2.4, Python 2.5, Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6514>
_______________________________________
More information about the Python-bugs-list
mailing list