UNITTEST problem!!! :(

andrea frosoni andrea.frosoni at mclink.it
Tue Feb 11 17:33:29 EST 2003


sorry peter

my traceback is :

======================================================================
FAIL: Test func1
----------------------------------------------------------------------
Traceback (most recent call last):
   File "pingtest.py", line 33, in testFunc1
     self.assertEqual(ret, 10, "ping.func1 did not work")
   File "C:\Python22\Lib\site-packages\unittest.py", line 273, in 
failUnlessEqua

     raise self.failureException, (msg or '%s != %s' % (first, second))
AssertionError: ping.func1 did not work
======================================================================
FAIL: Test func2
----------------------------------------------------------------------
Traceback (most recent call last):
   File "pingtest.py", line 40, in testFunc2
     self.failUnless(ret, "ping.func2 did not work")
   File "C:\Python22\Lib\site-packages\unittest.py", line 249, in failUnless
     if not expr: raise self.failureException, msg
AssertionError: ping.func2 did not work
----------------------------------------------------------------------
Ran 2 tests in 0.210s

FAILED (failures=2)

Thanks

Peter Hansen wrote:
> andrea frosoni wrote:
> 
>>the code listed down is correct???
>>don't work right
>>
>>Help me
>>
>>def testFunc1(self):
>>        "Test func1"
>>        # call func1
>>        ret = self.pingObj.func1(
>>            host = '194.183.3.41',              #sample host for ping
>>            num = '10')                         #number of packets sent
>>        self.assertEqual(ret, 10, "ping.func1 did not work")#10
>>number of                                               #packet shoud be return#
>>        return
>>
>>    def testFunc2(self):
>>        "Test func2"
>>        # call func2
>>        ret = self.pingObj.func2()
>>        self.failUnless(ret, "ping.func2 did not work")
>>        return
> 
> 
> Always *always* post the traceback for your failure, showing the 
> exact error message and the line of code that failed.  (Note: don't
> re-enter it either, just use cut-and-paste to stick it in the message.)
> 
> Without that, we don't know what didn't work and obviously cannot 
> run your code above as it is missing many necessary pieces.
> 
> Rather than make us come up with dozens of theories about what
> *might* have gone wrong, please just tell us.
> 
> (Theory 1: your indentation is screwed up because the first
> function seems to be indented 0 colummns, while the second
> one is indented four columns... I really doubt that's your
> only problem though, and it was probably just a side-effect
> of pasting the text in.)
> 
> -Peter





More information about the Python-list mailing list