UNITTEST problem!!! :(

Peter Hansen peter at engcorp.com
Tue Feb 11 22:54:36 EST 2003


[top-posting fixed]

andrea frosoni wrote:
> Peter Hansen wrote:
> > 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.)
> 
> my traceback is :
> 
> ======================================================================
> FAIL: Test func1
> ----------------------------------------------------------------------
[...]
> AssertionError: ping.func1 did not work
> ======================================================================
> FAIL: Test func2
> ----------------------------------------------------------------------
[...]
> AssertionError: ping.func2 did not work
> ----------------------------------------------------------------------
> Ran 2 tests in 0.210s
> 
> FAILED (failures=2)

As near as I can tell, the unit tests are working flawlessly
(at least, assuming they're really testing what you want them
to test).  You described this as a "UNITTEST problem!!!" which
I took to mean a problem with the unit test framework, but you
just meant your code is broken and you want help fixing it,
right?

In that case (since the above shows *failures* and not *errors*
in the unit test results), please post the code for ping.func1
if it's not too long, so we can analyze it.

It seems likely Chris hit the nail on the head though.

By the way, it's much more useful in your assertion messages
to show the expected and actual values.  For example, you 
could have done this instead, which would point you to the
problem more directly:

  self.assertEqual(ret, 10, "expected %r, got %r" % (10, ret))

and the result would basically prove that pingObj.func() was
not returning the right thing, and show what it *did* return.

-Peter




More information about the Python-list mailing list