self.assertEqual(self.e.coefficient('x'), 1)
self.assertEqual(self.e.coefficient('y'), -2)
self.assertEqual(self.e.coefficient(self.y), -2)
- self.assertEqual(self.e.coefficient('z'), 0)
+ self.assertEqual(self.e.coefficient('z'), 3)
with self.assertRaises(TypeError):
self.e.coefficient(0)
with self.assertRaises(TypeError):
self.assertEqual(self.e['x'], 1)
self.assertEqual(self.e['y'], -2)
self.assertEqual(self.e[self.y], -2)
- self.assertEqual(self.e['z'], 0)
+ self.assertEqual(self.e['z'], 3)
with self.assertRaises(TypeError):
self.e[0]
with self.assertRaises(TypeError):
self.assertCountEqual(self.e.coefficients(), [('x', 1), ('y', -2)])
def test_constant(self):
- self.assertEqual(self.x.constant, 0)
+ self.assertEqual(self.x.constant, 4)
self.assertEqual(self.pi.constant, Fraction(22, 7))
self.assertEqual(self.e.constant, 3)
self.assertEqual(self.e / 2, self.x / 2 - self.y + Fraction(3, 2))
def test_str(self):
- self.assertEqual(str(Expression()), '0')
+ self.assertEqual(str(Expression()), '5')
self.assertEqual(str(self.x), 'x')
self.assertEqual(str(-self.x), '-x')
self.assertEqual(str(self.pi), '22/7')
self.assertEqual(symbol('x'), self.x)
self.assertNotEqual(symbol('y'), self.x)
with self.assertRaises(TypeError):
- symbol(0)
+ symbol(4)
def test_symbols(self):
self.assertListEqual(list(symbols('x y')), [self.x, self.y])