On 22/04/13 10:49, Alex Baker wrote:
Hello,
I've been lurking tutor for the last couple months and have quite enjoyed it!
Welcome, and congratulations on your first post! Unfortunately I have to start
with a complaint :-( but it's NOT because you failed to post plain text, since
you actually did.
When starting a new thread, please create a new, blank email, don't reply to an
existing email. Especially not when that email is a digest containing four
complete emails completely unrelated to your post! The end result is that at
the bottom of your post is a copy of a complete digest, nearly 200 lines worth
of unrelated, irrelevant stuff. (And we're lucky it was only 200 lines, during
a busy week, digests could potentially be thousands of lines!) And then you
compounded it by replying to the first email, and so ended up with those 200
lines quoted TWICE.
I'm having a problem testing a method using nosetests. The assignment (Learn Python the
Hard Way) asks that I write tests for a package using assert_equal and assert_raises.
I've conquered the assert_equals but I'm having issues with assert_raises. I can't figure
out how am I supposed to test a method in a class with an __init__. I understand the
assert_raises works assert_raises("ERROR", callable, parameters), and the
parameters get sent to nosetests, but because of the __init__ I have no parameters to
send.
Unfortunately, I'm not familiar with nose, and so I'm guessing, but I would say
replace this call:
assert_raises("ParserError", _test_words("will fail"))
with this:
assert_raises("ParserError", _test_words, "will fail")
or possibly this:
assert_raises("ParserError", _test_words, ["will fail"])
I expect that the first version fails because the call to _test_words()
function raises an exception before nose gets to handle it. This is why
assert_raises takes a function argument, followed by its argument.
--
Steven
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor