[Tutor] Unexpected Behavior in unittest

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Feb 28 23:08:11 CET 2006


> In this case, the assignment to lg.cs failed.
> >>>>>>>>>>>>>>>>>>>>>>
> F
> ======================================================================
> FAIL: test_cs (__main__.cs_tryout)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "J:\My Documents\Projects\Mongoose\symgen\test3.py", line 25, in test_cs
>     self.assertEqual(expect, lg.cs, msg)
>   File "C:\PROGRA~1\Python23\lib\unittest.py", line 302, in failUnlessEqual
>     raise self.failureException, \
> AssertionError: Generator cs is incorrect.
> Expected 2.5; got 1.0
>

Hi Barry,

I think the bug here is less glamorous than you might expect.  I'd
recommend rerunning the unit test again, and watch carefully about what
exactly you're running.

It's strongly possible that you may be running the wrong test program: I
see a reference to a 'test3.py' there in the error message that dies on
the line:

    self.assertEqual(expect, lg.cs, msg)

But, hunting through the class that you've shown us, I see no such line.
*grin*

The simplest explanation is that you're not running the test program that
you think you're running.  Double check that you mean to run 'test3.py',
as opposed to some other 'test*' program in your working directory.


Good luck!





More information about the Tutor mailing list