homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Running tests inside a package by module name fails
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: eric.araujo, michael.foord
Priority: normal Keywords:

Created on 2011年02月10日 20:19 by michael.foord, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (3)
msg128337 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011年02月10日 20:19
Reported by a user and verified by me with both Python 2.7 and 3.2.
Trying to run tests by module or package name seems to fail.
directory structure:
 project root: C:\Users\hpierson\Projects\pytest
 \test
 __init__.py (empty)
 testfoo.py (sample test file
running test package by name - no tests discovered
C:\Users\hpierson\Projects\pytest
PS» cpy C:\Python31\Scripts\unit2.py test
----------------------------------------------------------------------
Ran 0 tests in 0.000s
 
running test module by name - can't find module
C:\Users\hpierson\Projects\pytest
PS» cpy C:\Python31\Scripts\unit2.py test.testfoo
Traceback (most recent call last):
 File "C:\Python31\Scripts\unit2.py", line 7, in <module>
 main_()
 File "C:\Python31\lib\site-packages\unittest2\main.py", line 237, in main_
 main(module=None)
 File "C:\Python31\lib\site-packages\unittest2\main.py", line 94, in __init__
 self.parseArgs(argv)
 File "C:\Python31\lib\site-packages\unittest2\main.py", line 149, in parseArgs
 self.createTests()
 File "C:\Python31\lib\site-packages\unittest2\main.py", line 158, in createTests
 self.module)
 File "C:\Python31\lib\site-packages\unittest2\loader.py", line 133, in loadTestsFromNames
 suites = [self.loadTestsFromName(name, module) for name in names]
 File "C:\Python31\lib\site-packages\unittest2\loader.py", line 133, in <listcomp>
 suites = [self.loadTestsFromName(name, module) for name in names]
 File "C:\Python31\lib\site-packages\unittest2\loader.py", line 101, in loadTestsFromName
 parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'testfoo'
msg135303 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011年05月06日 14:54
This isn't reproducable (any more?) on Python 2.7, but is on Python 3.2.
Running "python -m unittest package" doesn't find tests in submodules, but without running full discovery even when passed an explicit module name I don't think that is avoidable.
msg149808 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011年12月19日 00:43
No longer reproducable on CPython. Unfortunately still an issue with unittest2.
History
Date User Action Args
2022年04月11日 14:57:12adminsetgithub: 55387
2011年12月19日 00:43:25michael.foordsetstatus: open -> closed
resolution: out of date
messages: + msg149808
2011年05月23日 14:04:56eric.araujosetnosy: + eric.araujo
2011年05月06日 14:54:49michael.foordsetmessages: + msg135303
versions: + Python 3.3, - Python 2.7
2011年02月10日 20:19:07michael.foordcreate

AltStyle によって変換されたページ (->オリジナル) /