sympy/sympy — pull request #2283 by mattpap (2013-07-13 20:11:42+00:00)
Title: WIP: Added support for @XFAIL(exception, message) (#3945)

This fixes issue 3945. `XFAIL` decorator supports optional `exception` and `message` arguments. There are three variants: `@XFAIL`, `@XFAIL(Exception)`, `@XFAIL(Exception, "message")`. The first is equivalent to `@XFAIL(AssertionError)`. Only one exception is allowed. Currently `message` is compared exactly to `Exception`'s message. I rewrote all tests. In most cases this includes also exception message, but sometimes message depends on environment (e.g. `mpz` vs `int` or `0xdeadbeef`), so a few tests will have to be improved when matching of message is implemented. As a side effect I added coloring of tracebacks, using IPython's ultratb, because it was barely possible to read all those tracebacks (there were lots of failures). There are however a few issues with this:

[ ] `XFAIL` works in `py.test`, but `py.test` raises the following error every time `test_numerically` is used:
```
def test_numerically(f, g, z=None, tol=1.0e-6, a=2, b=-1, c=3, d=1):
fixture 'f' not found
available fixtures: pytestconfig, recwarn, monkeypatch, capfd, capsys, tmpdir
use 'py.test --fixtures [testpath]' for help on them.
```
[ ] `mpmath` fails with:
```
_____________________________________________________________________________________________________________________________________________
____________________________________ sympy/mpmath/tests/test_functions2.py:test_gegenbauer_unimplemented ____________________________________
Traceback (most recent call last):
File "/home/mateusz/repo/git/sympy/sympy/mpmath/tests/test_functions2.py", line 763, in test_gegenbauer_unimplemented
assert gegenbauer(-2, -0.5, 3).ae(-12)
File "sympy/mpmath/ctx_mp_python.py", line 1016, in f_wrapped
retval = f(ctx, *args, **kwargs)
File "sympy/mpmath/functions/orthogonal.py", line 316, in gegenbauer
raise NotImplementedError("Gegenbauer function with two limits")
NotImplementedError: Gegenbauer function with two limits
_____________________________________________________________________________________________________________________________________________
__________________________________________ sympy/mpmath/tests/test_gammazeta.py:test_gamma_failing __________________________________________
Traceback (most recent call last):
File "/home/mateusz/repo/git/sympy/sympy/mpmath/tests/test_gammazeta.py", line 196, in test_gamma_failing
assert gamma(Rational(1,2)) == gamma(0.5)
NameError: global name 'Rational' is not defined
_____________________________________________________________________________________________________________________________________________
______________________________________ sympy/mpmath/tests/test_gammazeta.py:test_gamma_huge_7_failing _______________________________________
Traceback (most recent call last):
File "/home/mateusz/repo/git/sympy/sympy/mpmath/tests/test_gammazeta.py", line 527, in test_gamma_huge_7_failing
assert str(y.imag) == "2.16735365342606e-1000"
NameError: global name 'y' is not defined
```

I'm not sure how to proceed with mpmath, because of its uncertain situation in sympy. Besides this all tests pass under 2.7, but I didn't check other configurations, so there may be other issues (especially with messages).