Hi Santosh!
Santosh Philip wrote:
> I am having some trouble with testing user defined exceptions
> ==============
> this one works
> ------------
> def anexception(arg):
> """just raise an exception with ValueError"""
> if arg == 5:
> raise ValueError, 'Just a ValueError'
>
> def test_anexception():
> """py.test for anexception"""
> import py.test
> py.test.raises(ValueError, anexception, 5)
>
> ===============
> this one does not work
> ---------------
> class MyError(Exception):
> """pass"""
> pass
>
> def anotherexception(arg):
> """just raise an exception with ValueError"""
> if arg == 5:
> raise MyError, 'its a MyError'
>
> def test_anotherexception():
> """py.test for anotherexception"""
> import py.test
> py.test.raises(ValueError, anotherexception, 5)
> ================
^^^^^^^^^^
Shouldn't this be "MyError"?
Btw: you don't need to say "import py.test". Just saying "import py"
is enough (py.test will be loaded only when it is used).
Cheers,
Carl Friedrich
_______________________________________________
_______________________________________________
py-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/py-dev