[Python-checkins] CVS: python/dist/src/Lib unittest.py,1.8,1.9
Steve Purcell
purcell@users.sourceforge.net
Wed, 08 Aug 2001 00:57:28 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv21572
Modified Files:
unittest.py
Log Message:
Merged in bugfix from PyUnit CVS for problem reported by Gary Todd.
If 'unittest.py' was run from the command line with the name of a test
case class as a parameter, it failed with an ugly error. (Which was a
shame, because the documentation says you can do that.)
The problem was the old 'is the class X that you imported from me the same
as my class X?' gotcha.
Index: unittest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/unittest.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** unittest.py 2001/05/10 01:28:40 1.8
--- unittest.py 2001/08/08 07:57:26 1.9
***************
*** 433,439 ****
obj = getattr(obj, part)
if type(obj) == types.ModuleType:
return self.loadTestsFromModule(obj)
! elif type(obj) == types.ClassType and issubclass(obj, TestCase):
return self.loadTestsFromTestCase(obj)
elif type(obj) == types.UnboundMethodType:
--- 433,440 ----
obj = getattr(obj, part)
+ import unittest
if type(obj) == types.ModuleType:
return self.loadTestsFromModule(obj)
! elif type(obj) == types.ClassType and issubclass(obj, unittest.TestCase):
return self.loadTestsFromTestCase(obj)
elif type(obj) == types.UnboundMethodType:
***************
*** 441,446 ****
elif callable(obj):
test = obj()
! if not isinstance(test, TestCase) and \
! not isinstance(test, TestSuite):
raise ValueError, \
"calling %s returned %s, not a test" % (obj,test)
--- 442,447 ----
elif callable(obj):
test = obj()
! if not isinstance(test, unittest.TestCase) and \
! not isinstance(test, unittest.TestSuite):
raise ValueError, \
"calling %s returned %s, not a test" % (obj,test)