On 01/07/2013 11:43 AM, Ronan Lamy wrote:
Le 07/01/2013 16:07, Alan Bromborsky a écrit :
I am using py.test to check my test scripts.  If I introduce multiple
errors in the script "my_test.py" and run "py.test my_test.py" it always
exits at the first error.  Is there a way to check for all assert errors
in the script?

How does it exit? What did you put in your script?

Try "py.test sympy/utilities" to see what to expect from a test run (you should see 2 failures: our test suite isn't fully compatible with py.test).

One problem I had was that in my_test.py I did not begin the names of the test functions with "test_". Now py.test checks each function, but if there are more than one error in each function it only prints out the first one in the function. "my_test.py" is shown below (note that you cannot execute it with current sympy)

import sys

from sympy import symbols,sin,cos
from GA import *

def test_basic_multivector_operations():
    (ex,ey,ez) = MV.setup('e*x|y|z')

    A = MV('A','mv')

assert str(A) == 'A + A__x*e_x + A__y*e_y + A__z*e_z + A__xy*e_x^e_y + A__xz*e_x^e_z + A__yz*e_y^e_z + A__xyz*e_x^e_y^e_z' assert str(A) == 'A + A__x*e_x + A__y*e_y + A__z*e_z + A__xy*e_x^e_y + A__xz*e_x^e_z + A__yz*e_y^e_z + A__xyz*e_x^e_y^e_z' assert str(A) == 'A + A__x*e_x + A__y*e_y + A__z*e_z + A__xy*e_x^e_y + A__xz*e_x^e_z + A__yz*e_y^e_z + A__xyz*e_x^e_y^e_z'

    X = MV('X','vector')
    Y = MV('Y','vector')

    assert str(X) == 'X__x*e_x + X__y*e_y + X__z*e_z'
    assert str(Y) == 'Y__x*e_x + Y__y*e_y + Y__z*e_z'

assert str((X*Y)) == '(e_x.e_x)*X__x*Y__x + (e_x.e_y)*X__x*Y__y + (e_x.e_y)*X__y*Y__x + (e_x.e_z)*X__x*Y__z + (e_x.e_z)*X__z*Y__x + (e_y.e_y)*X__y*Y__y + (e_y.e_z)*X__y*Y__z + (e_y.e_z)*X__z*Y__y + (e_z.e_z)*X__z*Y__z + (X__x*Y__y - X__y*Y__x)*e_x^e_y + (X__x*Y__z - X__z*Y__x)*e_x^e_z + (X__y*Y__z - X__z*Y__y)*e_y^e_z' assert str((X^Y)) == '(X__x*Y__y - X__y*Y__x)*e_x^e_y + (X__x*Y__z - X__z*Y__x)*e_x^e_z + (X__y*Y__z - X__z*Y__y)*e_y^e_z' assert str((X|Y)) == '(e_x.e_x)*X__x*Y__x + (e_x.e_y)*X__x*Y__y + (e_x.e_y)*X__y*Y__x + (e_x.e_z)*X__x*Y__z + (e_x.e_z)*X__z*Y__x + (e_y.e_y)*X__y*Y__y + (e_y.e_z)*X__y*Y__z + (e_y.e_z)*X__z*Y__y + (e_z.e_z)*X__z*Y__z'

    (ex,ey) = MV.setup('e*x|y')


    X = MV('X','vector')
    A = MV('A','spinor')

    assert str(X) == 'X__x*e_x + X__y*e_y'
    assert str(A) == 'A + A__xy*e_x^e_y'

assert str((X|A)) == '(A__xy*(-(e_x.e_y)*X__x - (e_y.e_y)*X__y))*e_x + (A__xy*((e_x.e_x)*X__x + (e_x.e_y)*X__y))*e_y' assert str((X<A)) == '(A__xy*(-(e_x.e_y)*X__x - (e_y.e_y)*X__y))*e_x + (A__xy*((e_x.e_x)*X__x + (e_x.e_y)*X__y))*e_y' assert str((A>X)) == '(A__xy*((e_x.e_y)*X__x + (e_y.e_y)*X__y))*e_x + (A__xy*(-(e_x.e_x)*X__x - (e_x.e_y)*X__y))*e_y'

    (ex,ey) = MV.setup('e*x|y',metric='[1,1]')

    X = MV('X','vector')
    A = MV('A','spinor')

    #Next line is error
    assert str(X) == '0'
    assert str(A) == 'A + A__xy*e_x^e_y'

assert str((X*A)) == '(A*X__x - A__xy*X__y)*e_x + (A*X__y + A__xy*X__x)*e_y'
    assert str((X|A)) == '-A__xy*X__y*e_x + A__xy*X__x*e_y'
    assert str((X<A)) == '-A__xy*X__y*e_x + A__xy*X__x*e_y'
    assert str((X>A)) == 'A*X__x*e_x + A*X__y*e_y'

assert str((A*X)) == '(A*X__x + A__xy*X__y)*e_x + (A*X__y - A__xy*X__x)*e_y'
    assert str((A|X)) == 'A__xy*X__y*e_x - A__xy*X__x*e_y'
    assert str((A<X)) == 'A*X__x*e_x + A*X__y*e_y'
    assert str((A>X)) == 'A__xy*X__y*e_x - A__xy*X__x*e_y'

def test_check_generalized_BAC_CAB_formulas():

    (a,b,c,d) = MV.setup('a b c d')

    #Next line is error
    assert str(a|(b*c)) == '(a.c)*b + (a.b)*c'
    assert str(a|(b^c)) == '-(a.c)*b + (a.b)*c'
    assert str(a|(b^c^d)) == '(a.d)*b^c - (a.c)*b^d + (a.b)*c^d'
    assert str((a|(b^c))+(c|(a^b))+(b|(c^a))) == '0'
    #Next line is error
    assert str(a*(b^c)-b*(a^c)+c*(a^b)) == '4*a^b^c'
    assert str(a*(b^c^d)-b*(a^c^d)+c*(a^b^d)-d*(a^b^c)) == '4*a^b^c^d'
    assert str((a^b)|(c^d)) == '-(a.c)*(b.d) + (a.d)*(b.c)'
    assert str(((a^b)|c)|d) == '-(a.c)*(b.d) + (a.d)*(b.c)'
assert str(Com(a^b,c^d)) == '-(b.d)*a^c + (b.c)*a^d + (a.d)*b^c - (a.c)*b^d'

--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to