testloader does not help with modules that cannot be imported

Bug #681045 reported by Jonathan Lange
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Testrepository
Invalid
Wishlist
Unassigned
testtools
Triaged
Wishlist
Unassigned

Bug Description

When running testr's own tests using testr, when there's some kind of failure preventing one of the tests from importing correctly, you get an error like this:

$ testr run
running=python -m subunit.run testrepository.tests.test_suite| testr load
Traceback (most recent call last):
  File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.6/dist-packages/subunit/run.py", line 72, in <module>
    SubunitTestProgram(module=None, argv=sys.argv, testRunner=runner)
  File "/usr/lib/python2.6/dist-packages/testtools/run.py", line 133, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python2.6/dist-packages/testtools/run.py", line 188, in parseArgs
    self.createTests()
  File "/usr/lib/python2.6/dist-packages/testtools/run.py", line 199, in createTests
    self.module)
  File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.6/unittest.py", line 598, in loadTestsFromName
    test = obj()
  File "testrepository/tests/__init__.py", line 70, in test_suite
    suite = loader.loadTestsFromNames(module_names)
  File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.6/unittest.py", line 584, in loadTestsFromName
    parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'test_arguments'
id=2, tests=0

Many other test runners (e.g. trial, zope.testrunner) do substantially better than this.

Revision history for this message
Robert Collins (lifeless) wrote :

This needs testtools help.

Revision history for this message
Jonathan Lange (jml) wrote :

I'm not 100% sure what needs to be done here, but I expect it'll come quickly enough.

Changed in testtools:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Robert Collins (lifeless) wrote :

What it needs is a replacement test loader that handles import failures in a more graceful way, e.g. the way bzr's does. Theres a bug open on python for doing that. When such a loader is available, this can be moved forward is testrepository.

Changed in testrepository:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
Robert Collins (lifeless) wrote :

I'm marking the testrepository task invalid: While its true it needs to change to use this, theres nothing actually causing the bug in testrepository.

summary: - Bad error when running tests that fail to import
+ testloader does not help with modules that cannot be imported
Changed in testrepository:
status: Triaged → Invalid
Changed in testtools:
importance: High → Wishlist
Revision history for this message
James Westby (james-w) wrote :

http://bugs.python.org/issue7559 is the Python bug.

Thanks,

James

Revision history for this message
Robert Collins (lifeless) wrote :

I believe this is all fixed now. Could you please confirm?

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.