- def test_symbols(self):
- self.assertListEqual(list(symbols('x y')), [self.x, self.y])
- self.assertListEqual(list(symbols('x,y')), [self.x, self.y])
- self.assertListEqual(list(symbols(['x', 'y'])), [self.x, self.y])
+
+class TestDummy(unittest.TestCase):
+
+ def setUp(self):
+ self.x = Dummy('x')
+
+ def test_new(self):
+ self.assertEqual(self.x.name, 'x')
+ self.assertTrue(Dummy().name.startswith('Dummy'))
+
+ def test_eq(self):
+ self.assertEqual(self.x, self.x)
+ self.assertNotEqual(self.x, Symbol('x'))
+ self.assertNotEqual(Symbol('x'), self.x)
+ self.assertNotEqual(self.x, Dummy('x'))
+ self.assertNotEqual(Dummy(), Dummy())
+
+ def test_repr(self):
+ self.assertEqual(repr(self.x), '_x')
+ dummy1 = Dummy()
+ dummy2 = Dummy()
+ self.assertTrue(repr(dummy1).startswith('_Dummy_'))
+ self.assertNotEqual(repr(dummy1), repr(dummy2))
+
+
+class TestSymbols(unittest.TestCase):
+
+ def setUp(self):
+ self.x = Symbol('x')
+ self.y = Symbol('y')
+
+ def test(self):
+ self.assertTupleEqual(symbols('x y'), (self.x, self.y))
+ self.assertTupleEqual(symbols('x,y'), (self.x, self.y))
+ self.assertTupleEqual(symbols(['x', 'y']), (self.x, self.y))
+ with self.assertRaises(TypeError):
+ symbols(1)
+ with self.assertRaises(TypeError):
+ symbols(['a', 1])