Problem with Unittest:

Matt Brubeck mbrubeck at cs.hmc.edu
Tue May 13 12:33:04 EDT 2003


"Frithiof Andreas Jensen" <frithiof.jensen at removethis.ted.ericsson.dk> wrote in message news:<b9r15s$1v$1 at newstree.wise.edt.ericsson.se>...

> Traceback (most recent call last):
>   File "C:\tedfrje\traders_toolkit\test_duffer.py", line 12, in test_duffer
>     self.assertRaises(ValueError(), duffer())
>   File "C:\tedfrje\traders_toolkit\test_duffer.py", line 7, in duffer
>     raise ValueError()
> ValueError

You probably need to change this line:
    self.assertRaises(ValueError(), duffer())
to this:
    self.assertRaises(ValueError, duffer)

> FAILED (errors=1)
> 
> In my opinion, the script should PASS because I specified that a
> ValueError() was the PASS criteria.

In this case, the ValueError was not raised by "duffer" as intended. 
Instead it was raised because you passed duffer() to assertRaises,
which expects a callable object.




More information about the Python-list mailing list