Issue link: http://code.google.com/p/sympy/issues/detail?id=2867
The idea here is to have a lambda expression instead of a string.
I.e. instead of
>>> raises(TypeError, "Rational(2)*MyInt")
we want
>>> raises(TypeError, lambda: Rational(2)*MyInt)
This works very well, except when the code needs to test a statement
instead of an exception. I'd like to hear how to deal with these.
Here's the full list of remaining cases, grouped by constellation:
A) Testing nonassignability:
sympy/core/tests/test_assumptions.py, line 393:
raises(AttributeError, "x.is_real = False")
sympy/core/tests/test_containers.py, line 101:
raises(NotImplementedError, "d[5] = 6") # assert immutability
sympy/matrices/tests/test_matrices.py, line 1590:
raises(ValueError, "SparseMatrix([[1, 2], [3, 4]])[1, 2, 3] = 4")
B) Testing that a wrong import statement fails:
sympy/core/tests/test_numbers.py, line 538:
raises(ImportError, 'from sympy import Pi')
Comments? Ideas?
My thinking right now is:
A) Find or write a function that tests assignability.
C) I suspect this can't be wrapped in a function. If that single case is
all and there's no risk of ever having more test cases like this, I'd
find it acceptable to replace the raises() call with an explicit
try...catch sequence.
Regards,
Jo
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.