Issue #183 resolved

AttributeError: test command fails with NoneType object has no attribute 'run'

Jason R. Coombs
created an issue

Arfrever Frehtes Taifersar Arahesis reports that the recent change to support custom test loaders (d9932598b86f) now causes AttributeErrors when no testLoader is supplied on Python 2.6 and 3.1.

Comments (7)

  1. Jason R. Coombs reporter

    Arfrever suggested this patch which almost surely would work, but it would mask the purpose of the code. Especially when supporting cross-python compatibility, I would prefer to have a wrapped to capture the compatibility logic (and thus describe when the compatibility logic is safe to remove, in this case after Python 2.6/3.1 is dropped).

  2. Arfrever Frehtes Taifersar Arahesis

    (I mentioned only Python 3.1 on IRC.)

    Content of my patch for historical reference:

    diff --git a/setuptools/command/ b/setuptools/command/
    --- a/setuptools/command/
    +++ b/setuptools/command/
    @@ -158,11 +158,12 @@
                     list(map(sys.modules.__delitem__, del_modules))
    -        unittest.main(
    -            None, None, [unittest.__file__]+self.test_args,
    -            testLoader=self._resolve_as_ep(self.test_loader),
    -            testRunner=self._resolve_as_ep(self.test_runner),
    -        )
    +        kwargs = {}
    +        if self.test_loader is not None:
    +            kwargs["testLoader"] = self._resolve_as_ep(self.test_loader)
    +        if self.test_runner is not None:
    +            kwargs["testRunner"] = self._resolve_as_ep(self.test_runner)
    +        unittest.main(None, None, [unittest.__file__]+self.test_args, **kwargs)
         def _resolve_as_ep(val):
  3. Arfrever Frehtes Taifersar Arahesis

    369f6f90f696 does not work:

    Traceback (most recent call last):
      File "", line 217, in <module>
        dist = setuptools.setup(**setup_params)
      File "/usr/lib64/python3.1/distutils/", line 149, in setup
      File "/usr/lib64/python3.1/distutils/", line 919, in run_commands
      File "/usr/lib64/python3.1/distutils/", line 938, in run_command
      File "", line 68, in run
      File "/tmp/setuptools/setuptools/command/", line 146, in run
      File "/tmp/setuptools/setuptools/command/", line 127, in with_project_on_sys_path
      File "/tmp/setuptools/setuptools/command/", line 167, in run_tests
      File "/tmp/setuptools/setuptools/", line 52, in unittest_main
        return unittest.main(*args, **kwargs)
      File "/usr/lib64/python3.1/", line 1573, in __init__
      File "/usr/lib64/python3.1/", line 1618, in runTests
        self.result =
    AttributeError: 'TestLoader' object has no attribute 'run'
  4. Log in to comment