Exemplo n.º 1
0
    def test_persistent_types_buglets(self):

        l = PersistentList([1, 2, 3])
        self.assertTrue(isinstance(l, PersistentList))
        self.assertFalse(isinstance(l, list))  # dangerous
        self.assertTrue(isinstance(l[:], PersistentList))

        d = PersistentMapping({1: 2})
        self.assertTrue(isinstance(d, PersistentMapping))
        self.assertFalse(isinstance(d, dict))  # dangerous
        self.assertTrue(isinstance(d.copy(), PersistentMapping))
Exemplo n.º 2
0
    def test_mapping_copy(self):

        a = PersistentMapping(dict(a=3, b=5))
        b = a.copy()
        c = copy.copy(a)

        assert a == b
        assert a == c
        assert a is not b
        assert a is not c
        assert b is not c

        del a["a"]
        assert b["a"]  # NOT impacted
        assert c["a"]  # NOT impacted
Exemplo n.º 3
0
    def test_mapping_copy(self):
        a = PersistentMapping(dict(a=3, b=5))
        b = a.copy()
        c = copy.copy(a)
        d = copy.deepcopy(a)

        assert a == b
        assert a == c
        assert a == d
        assert a is not b
        assert a is not c
        assert b is not c
        assert a is not d

        del a["a"]
        assert b["a"]  # NOT impacted
        assert "a" in c  # NOT impacted
        assert d["a"]  # NOT impacted