1from diofant import Symbol, exp 2 3 4__all__ = () 5 6 7def test_equal(): 8 b = Symbol('b') 9 a = Symbol('a') 10 e1 = a + b 11 e2 = 2*a*b 12 e3 = a**3*b**2 13 e4 = a*b + b*a 14 assert not e1 == e2 15 assert not e1 == e2 16 assert e1 != e2 17 assert e2 == e4 18 assert e2 != e3 19 assert not e2 == e3 20 21 x = Symbol('x') 22 e1 = exp(x + 1/x) 23 y = Symbol('x') 24 e2 = exp(y + 1/y) 25 assert e1 == e2 26 assert not e1 != e2 27 y = Symbol('y') 28 e2 = exp(y + 1/y) 29 assert not e1 == e2 30 assert e1 != e2 31 32 e5 = 3 + 2*x - x - x 33 assert e5 == 3 34 assert 3 == e5 35 assert e5 != 4 36 assert 4 != e5 37 assert e5 != 3 + x 38 assert 3 + x != e5 39 40 41def test_expevalbug(): 42 x = Symbol('x') 43 e1 = exp(1*x) 44 e3 = exp(x) 45 assert e1 == e3 46 47 48def test_cmp_bug1(): 49 class T: 50 pass 51 52 t = T() 53 x = Symbol('x') 54 55 assert not x == t 56 assert x != t 57 58 59def test_cmp_bug2(): 60 class T: 61 pass 62 63 t = T() 64 65 assert not Symbol == t 66 assert Symbol != t 67 68 69def test_cmp_sympyissue_4357(): 70 assert not (Symbol == 1) 71 assert (Symbol != 1) 72 assert not (Symbol == 'x') 73 assert (Symbol != 'x') 74