def test_communication_deep_copy(self): comm1 = create_comm('a-b-c', text='foo bar baz .') comm2 = communication_deep_copy(comm1) comm3 = communication_deep_copy(comm1) self.assert_simple_comms_equal(comm1, comm2) self.assert_simple_comms_equal(comm2, comm3) tkzn1 = comm1.sectionList[0].sentenceList[0].tokenization tkzn1.tokenList.tokenList[0] = Token(text='bbq', tokenIndex=0) tkzn2 = comm2.sectionList[0].sentenceList[0].tokenization self.assertNotEqual( map(lambda t: t.text, tkzn1.tokenList.tokenList), map(lambda t: t.text, tkzn2.tokenList.tokenList), ) self.assert_simple_comms_equal(comm2, comm3)
def compress(self, comm): 'Return a deep copy of comm with compressed UUIDs.' cc = communication_deep_copy(comm) self.augf = AnalyticUUIDGeneratorFactory(cc) self.augs = dict() self.uuid_map = dict() self._compress_uuids(cc) self._compress_uuid_refs(cc) return cc