Title: Running tests inside a package by module name fails
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.2, Python 3.3
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 2011-12-19 00:43 by michael.foord. 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
   (sample test file

running test package by name - no tests discovered

PS» cpy C:\Python31\Scripts\ test

Ran 0 tests in 0.000s


running test module by name - can't find module

PS» cpy C:\Python31\Scripts\ test.testfoo
Traceback (most recent call last):
  File "C:\Python31\Scripts\", line 7, in <module>
  File "C:\Python31\lib\site-packages\unittest2\", line 237, in main_
  File "C:\Python31\lib\site-packages\unittest2\", line 94, in __init__
  File "C:\Python31\lib\site-packages\unittest2\", line 149, in parseArgs
  File "C:\Python31\lib\site-packages\unittest2\", line 158, in createTests
  File "C:\Python31\lib\site-packages\unittest2\", line 133, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "C:\Python31\lib\site-packages\unittest2\", line 133, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "C:\Python31\lib\site-packages\unittest2\", 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.
Date User Action Args
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