[ python-Bugs-878275 ] Handle: class MyTest(unittest.TestSuite)
SourceForge.net
noreply at sourceforge.net
Sun Nov 7 16:53:38 CET 2004
Bugs item #878275, was opened at 2004-01-16 15:22
Message generated for change (Comment added) made by jlgijsbers
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=878275&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 6
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Steve Purcell (purcell)
Summary: Handle: class MyTest(unittest.TestSuite)
Initial Comment:
TestCases are supposed to be derived from
unittest.TestCase; however, if they are derived from
unittest.TestSuite, the traceback is inexplicable and
hard to diagnose:
Traceback (most recent call last):
File "C:/pydev/tmp.py", line 10, in -toplevel-
unittest.TextTestRunner(verbosity=2).run(suite)
File "C:\PY24\lib\unittest.py", line 690, in run
test(result)
File "C:\PY24\lib\unittest.py", line 423, in __call__
test(result)
File "C:\PY24\lib\unittest.py", line 423, in __call__
test(result)
File "C:\PY24\lib\unittest.py", line 423, in __call__
test(result)
TypeError: 'str' object is not callable
Let's either improve the error message or make it
possible to derive from TestSuite.
The above traceback is produced by the following script:
import unittest
class TestStats(unittest.TestSuite):
def testtwo(self):
self.assertEqual(2,2)
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestStats))
unittest.TextTestRunner(verbosity=2).run(suite)
----------------------------------------------------------------------
>Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2004-11-07 16:53
Message:
Logged In: YES
user_id=469548
Well, the error message above has been fixed, but here's
another equally confusing variant:
import unittest
class TestStats(unittest.TestSuite):
def testtwo(self):
self.assertEqual(2,2)
suite = unittest.TestSuite([TestStats])
unittest.TextTestRunner(verbosity=2).run(suite)
giving:
Traceback (most recent call last):
File "test-foo.py", line 8, in ?
unittest.TextTestRunner(verbosity=2).run(suite)
File "/home/johannes/python/Lib/unittest.py", line 695, in run
test(result)
File "/home/johannes/python/Lib/unittest.py", line 426, in
__call__
test(result)
File "/home/johannes/python/Lib/unittest.py", line 396, in
__init__
self.addTests(tests)
File "/home/johannes/python/Lib/unittest.py", line 416, in
addTests
for test in tests:
TypeError: iteration over non-sequence
so I'm leaving this open.
----------------------------------------------------------------------
Comment By: Irmen de Jong (irmen)
Date: 2004-11-07 14:39
Message:
Logged In: YES
user_id=129426
patch is at #1061904
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=878275&group_id=5470
More information about the Python-bugs-list
mailing list