def test_getStorage(self): c = RAMCache() c.maxAge = 123 c.maxEntries = 2002 c.cleanupInterval = 42 storage1 = c._getStorage() storage2 = c._getStorage() self.assertEqual(storage1, storage2, "_getStorage returns different storages") self.assertEqual(storage1.maxAge, 123, "maxAge not set (expected 123, got %s)" % storage1.maxAge) self.assertEqual(storage1.maxEntries, 2002, "maxEntries not set (expected 2002, got %s)" % storage1.maxEntries) self.assertEqual(storage1.cleanupInterval, 42, "cleanupInterval not set (expected 42, got %s)" % storage1.cleanupInterval) # Simulate persisting and restoring the RamCache which removes # all _v_ attributes. for k in c.__dict__.keys(): if k.startswith('_v_'): del c.__dict__[k] storage2 = c._getStorage() self.assertEqual(storage1, storage2, "_getStorage returns different storages")