+ def test_fromsympy(self):
+ import sympy
+ sp_x, sp_y = sympy.symbols('x y')
+ self.assertEqual(Expression.fromsympy(sp_x), self.x)
+ self.assertEqual(Expression.fromsympy(sympy.Rational(22, 7)), self.pi)
+ self.assertEqual(Expression.fromsympy(sp_x - 2*sp_y + 3), self.expr)
+ with self.assertRaises(ValueError):
+ Expression.fromsympy(sp_x*sp_y)
+
+ def test_tosympy(self):
+ import sympy
+ sp_x, sp_y = sympy.symbols('x y')
+ self.assertEqual(self.x.tosympy(), sp_x)
+ self.assertEqual(self.pi.tosympy(), sympy.Rational(22, 7))
+ self.assertEqual(self.expr.tosympy(), sp_x - 2*sp_y + 3)
+