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.

Author james-w
Recipients exarkun, james-w, michael.foord, rbcollins
Date 2010-08-21.01:07:37
SpamBayes Score 1.1431843e-05
Marked as misclassified No
Message-id <1282352860.8.0.988983335553.issue7501@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,

I think this was misdiagnosed:

from unittest.py in 2.6, loadTestFromName:

        elif hasattr(obj, '__call__'):
            test = obj()
            if isinstance(test, TestSuite):
                return test
            elif isinstance(test, TestCase):
                return TestSuite([test])
            else:
                raise TypeError("calling %s returned %s, not a test" %
                                (obj, test))

so it supports callables, such as the test_suite function that
Rob is passing. Therefore I don't think this is a feature request,
and "use load_tests" isn't an appropriate resolution.

I haven't checked what 2.7 and later do, but going on the above
my diagnosis of this is the following.

  1. test_suite is correctly identified as a callable
  2. It is called an returns a unittest.TestSuite
  3. It is not matched as being a a TestSuite or a TestCase, and so the error is raised.

The reason it is not matched is that when run as -m unittest, the unittest module is __main__, and so the TestSuite in the isinstance check is a unittest.TestSuite against a __main__.TestSuite, which won't match.

Therefore I think this is a legitimate bug, in at least 2.6.

Thanks,

James
History
Date User Action Args
2010-08-21 01:07:41james-wsetrecipients: + james-w, exarkun, rbcollins, michael.foord
2010-08-21 01:07:40james-wsetmessageid: <1282352860.8.0.988983335553.issue7501@psf.upfronthosting.co.za>
2010-08-21 01:07:38james-wlinkissue7501 messages
2010-08-21 01:07:37james-wcreate