Duncan Booth <[EMAIL PROTECTED]> writes:
> An assignment expression, if such a thing existed wouldn't help here.
> 
> The point being that the expression must be evaluated inside the exception 
> handler in assertRaises, so you either need to delay the evaluation with a 
> lambda, or by passing the function and arguments in separately. If you had 
> an assignment expression it would be roughly equivalent to:
> 
>    self.assertRaises(AttributeError, setattr(self.combat, 'value', 1))
> 
> which will throw the AttributeError instead of passing the test.

Yes.  The example I quoted used an assignment expression inside a
lambda.  The person who posted it, and the person who followed it up
with the setattr alternative, both didn't notice that the assignment
expression wasn't valid Python.  However, my post came out sounding
grumpier than I intended ;).
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to