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.

classification
Title: Putting a function in a unittest.TestSuite doesn't work
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: michael.foord
Priority: normal Keywords:

Created on 2010-04-03 13:32 by michael.foord, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg102259 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-04-03 13:32
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
    self._wrapped_run(result)
  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'
msg105318 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-05-08 17:06
Committed revision 80997.
History
Date User Action Args
2022-04-11 14:56:59adminsetgithub: 52548
2010-05-08 17:06:53michael.foordsetstatus: open -> closed
resolution: accepted
messages: + msg105318

stage: needs patch -> resolved
2010-04-03 13:32:03michael.foordcreate