Ejemplo n.º 1
0
    def test_cell_equality(self):
        """
        test_cell_equality: required for expected set behaviour
        """
        table = xypath.Table()

        cell_a = xypath._XYCell("foo", 1, 3, table)
        also_cell_a = xypath._XYCell("foo", 1, 3, table)

        self.assertIsNot(cell_a, also_cell_a)
        self.assertEqual(cell_a, also_cell_a)
Ejemplo n.º 2
0
    def test_cell_equality(self):
        """
        test_cell_equality: required for expected set behaviour
        """
        table = xypath.Table()

        cell_a = xypath._XYCell("foo", 1, 3, table)
        also_cell_a = xypath._XYCell("foo", 1, 3, table)

        self.assertIsNot(cell_a, also_cell_a)
        self.assertEqual(cell_a, also_cell_a)
Ejemplo n.º 3
0
 def test_cell_identity_not_equal_different_y(self):
     table = xypath.Table()
     cell_a = xypath._XYCell("foo", 1, 3, table)
     not_cell_a = copy(cell_a)
     not_cell_a.y = 2
     self.assertNotEqual(hash(cell_a), hash(not_cell_a))
     self.assertEqual(2, len(set([cell_a, not_cell_a])))
Ejemplo n.º 4
0
    def test_cell_copy(self):
        table = xypath.Table()

        cell_a = xypath._XYCell("foo", 1, 3, table)
        not_cell_a = copy(cell_a)
        # Before mutating "not_cell_a", ensure that it is first equal
        self.assertEqual(hash(cell_a), hash(not_cell_a))
Ejemplo n.º 5
0
 def test_cell_identity_not_equal_different_y(self):
     table = xypath.Table()
     cell_a = xypath._XYCell("foo", 1, 3, table)
     not_cell_a = copy(cell_a)
     not_cell_a.y = 2
     self.assertNotEqual(hash(cell_a), hash(not_cell_a))
     self.assertEqual(2, len(set([cell_a, not_cell_a])))
Ejemplo n.º 6
0
    def test_cell_copy(self):
        table = xypath.Table()

        cell_a = xypath._XYCell("foo", 1, 3, table)
        not_cell_a = copy(cell_a)
        # Before mutating "not_cell_a", ensure that it is first equal
        self.assertEqual(hash(cell_a), hash(not_cell_a))
Ejemplo n.º 7
0
    def test_cell_identity(self):
        """
        test_cell_identity: given two cells which were instantiated separately
        but *actually* belong to the same logical cell (table, co-ordinate,
        value), ensure that their identity (as far as the 'set' type is
        concerned) is maintained.
        """

        table = xypath.Table()

        cell_a = xypath._XYCell("foo", 1, 3, table)
        also_cell_a = xypath._XYCell("foo", 1, 3, table)

        self.assertIsNot(cell_a, also_cell_a)
        self.assertEqual(hash(cell_a), hash(also_cell_a))

        self.assertEqual(1, len(set([cell_a, also_cell_a])))
Ejemplo n.º 8
0
    def test_cell_identity(self):
        """
        test_cell_identity: given two cells which were instantiated separately
        but *actually* belong to the same logical cell (table, co-ordinate,
        value), ensure that their identity (as far as the 'set' type is
        concerned) is maintained.
        """

        table = xypath.Table()

        cell_a = xypath._XYCell("foo", 1, 3, table)
        also_cell_a = xypath._XYCell("foo", 1, 3, table)

        self.assertIsNot(cell_a, also_cell_a)
        self.assertEqual(hash(cell_a), hash(also_cell_a))

        self.assertEqual(1, len(set([cell_a, also_cell_a])))
Ejemplo n.º 9
0
 def test_cell_shift_takes_tuples(self):
     table = xypath.Table()
     cell = xypath._XYCell("foo", 1, 3, table)
     table.add(cell)
     cell.shift([0, 0])
Ejemplo n.º 10
0
 def test_cell_shift_takes_tuples(self):
     table = xypath.Table()
     cell = xypath._XYCell("foo", 1, 3, table)
     table.add(cell)
     cell.shift([0,0])