On Aug 4, 2006, at 9:10 PM, Jorge Vargas wrote:

On 8/4/06, Kevin Dangoor <[EMAIL PROTECTED]> wrote:

On Aug 4, 2006, at 1:46 AM, Jorge Vargas wrote:

Hi

I have been reading about nose and I find it great.

I have been looking into TG's test and all exceptions related are like this, so say the exception name in the string but what if I must be sure that I get exception type X
    try:
w.name = "foo"
assert False, "should have gotten an exception"
except ValueError:
pass

I have this, but it will actually fail all the time,

It fails all the time because you can't get the exception to raise?

sorry I was refering to the second code, the one that has
except <someException>:
    assert True
asser False

What you have above is generally what I do, but if I'm testing for an exception there's usually a way to make the exception come up.

yes but you can only assert that a exception was raised not exception type X w.name="foo" could have given anything other then what I want it to raise. and the test will still "pass"



I'm not sure what you mean. That except clause up there will only handle ValueErrors. Anything else that comes up will "error" the test. (Not a failure, mind you, but it still wouldn't pass..)

You could also use a boolean if you want.

got_exception = False
try:
    do_something()
except NotImplementedError:
    got_exception = True
assert got_exception

Kevin




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to