def test_number_number_equality(self): three = test_py3c.Number(3) three2 = test_py3c.Number(3) five = test_py3c.Number(5) self.assertEqual(three, three) self.assertEqual(three, three2) self.assertNotEqual(three, five)
def test_all_comparisons(self): three = test_py3c.Number(3) three2 = test_py3c.Number(3) five = test_py3c.Number(5) for op in (operator.eq, operator.ne, operator.gt, operator.lt, operator.ge, operator.le): self.assertEqual(op(three, three), op(3, 3)) self.assertEqual(op(three, three2), op(3, 3)) self.assertEqual(op(three, five), op(3, 5)) self.assertEqual(op(five, three), op(5, 3)) self.assertEqual(op(three, 3), op(3, 3)) self.assertEqual(op(3, three), op(3, 3)) self.assertEqual(op(three, 5), op(3, 5)) self.assertEqual(op(5, three), op(5, 3))
def test_number_int_equality(self): three = test_py3c.Number(3) five = test_py3c.Number(5) self.assertEqual(three, 3) self.assertNotEqual(three, 5)
def test_number(self): num = test_py3c.Number(3) self.assertEqual(num.value, 3) num.value = 5 self.assertEqual(num.value, 5)