Ejemplo n.º 1
0
    def test_owner(self):
        expr2 = Expression('test', 'fish', op=OP_SUB)
        expr1 = Expression(1, 2, expr2, op=OP_ADD)
        mock_owner = MockOwner()

        expr1.owner = mock_owner
        self.assertEqual(id(expr1._owner_ref()), id(expr2._owner_ref()))
Ejemplo n.º 2
0
    def test_copy(self):
        expr = Expression(1, 2, 3, Expression(1, 3, 4), op=OP_SUB)
        mock_owner = MockOwner()
        expr.owner = mock_owner
        expr_copy = copy.copy(expr)

        self.assertNotEqual(id(expr), id(expr_copy))
        self.assertNotEqual(id(expr._tokens), id(expr_copy._tokens))
        self.assertEqual(
            [id(t) for t in expr._tokens],
            [id(t) for t in expr_copy._tokens])
        self.assertEqual(expr.alias, expr_copy.alias)
        self.assertEqual(id(expr._owner_ref()), id(expr_copy._owner_ref()))