def testSerialization(self): sobject = self.constructData() filepath = self.getTestFilepath() #test writing to file stream with open(filepath, 'w') as fStream: sobject.serialize(fStream) #test reading from file stream with open(filepath) as fStream: SObject.UnserializeStream(fStream) filepath.delete() assert not filepath.exists() #test writing and reading from disk sobject.write(filepath) assert filepath.exists() unserialized = SObject.Load(filepath) assert unserialized == sobject print sobject