[New-bugs-announce] [issue8301] Putting a function in a unittest.TestSuite doesn't work

Michael Foord report at bugs.python.org
Sat Apr 3 15:32:04 CEST 2010

New submission from Michael Foord <michael at voidspace.org.uk>:

Putting functions (rather than TestCase instances) directly in TestSuites was never officially supported but it used to work:

>>> from unittest import TestSuite, TestResult
>>> def f(): pass
>>> s = TestSuite()
>>> s.addTest(f)
>>> s.run(TestResult())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/compile/python-trunk/Lib/unittest/suite.py", line 85, in run
  File "/compile/python-trunk/Lib/unittest/suite.py", line 100, in _wrapped_run
    self._handleClassSetUp(test, result)
  File "/compile/python-trunk/Lib/unittest/suite.py", line 122, in _handleClassSetUp
    currentClass._classSetupFailed = False
TypeError: can't set attributes of built-in/extension type 'function'

assignee: michael.foord
components: Library (Lib)
messages: 102259
nosy: michael.foord
severity: normal
stage: needs patch
status: open
title: Putting a function in a unittest.TestSuite doesn't work
type: behavior
versions: Python 2.7, Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list