[i tangled with this exact same thing recently]
By design, there should be one test per testcase instance. That is,
each test case is designed to be 100% standalone.
I ran into the same problem and did this:
def check_100_PerformAllInOrderTests(self):
"""Perform all order dependent tests as single atomic operation
against single instance of TestCase."""
inorderCases = getTestCaseNames(self.__class__, "inorder", )
for aCase in inorderCases:
self.__class__.__dict__[aCase](self)
def inorder_100_CreateSession(self):
....
def inorder_101_TestMissingNameSubmission(self):
....
def inorder_102_TestTooLongNameSubmission(self):
....
... etc ....
I always put #s in my test method names out of habit. Makes life easier
when the developers can refer to "Test ####" as opposed to yelling names
back and forth while pair programming.
b.bum
On Friday, June 8, 2001, at 05:06 PM, Keith, David wrote:
>
> Is there any way to have multiple check_ methods be invoked without a
> new TestCase class being created? For example:
>
> class CadMain_Model (unittest.TestCase):
>
>
> #---------------------------------------------------------------------------
> def __init__ (self, methodName='runTest'):
> print "model test ctor"
> unittest.TestCase.__init__ (self, methodName)
>
>
> #---------------------------------------------------------------------------
> def setUp (self):
> "my setup code goes here"
>
>
> #---------------------------------------------------------------------------
> def check_test1 (self):
> "my first test"
>
>
> #---------------------------------------------------------------------------
> def check_test2 (self):
> "my second test"
>
> ... more checks ...
>
> def allTests ():
> allSuites = unittest.TestSuite()
> allSuites.addTest(unittest.makeSuite(CadMain_Model, 'check'))
> return allSuites
>
> suite = allTests()
> runner = unittest.TextTestRunner()
> runner.run (suite)
>
> The CadMain_Model class is instantiated for check_test1() and then
> again for check_test2. I'd like to have the class instantiated and the
> setUp() code run followed by all the check_* methods being called
> (without a new instance and setup)?
>
> Any way to do that short of moving my setUp() code to the module level
> (which I'd rather not do)?
>
>
> _______________________________________________
> Pyunit-interest mailing list
> Pyu...@li...
> http://lists.sourceforge.net/lists/listinfo/pyunit-interest
|