Ejemplo n.º 1
0
 def test_d_weakref_behaviour(self):
     tf1 = template_files.TemplateFiles(template_files_1)
     tf1.store()
     tf2 = template_files.TemplateFiles(tf1)
     del tf1.files
     self.assertIn(tf2.files_id, template_files._d)
     del tf2.files
     self.assertNotIn(tf2.files_id, template_files._d)
Ejemplo n.º 2
0
 def test_d_weakref_behaviour(self):
     ctx = utils.dummy_context()
     tf1 = template_files.TemplateFiles(template_files_1)
     tf1.store(ctx)
     tf2 = template_files.TemplateFiles(tf1)
     del tf1.files
     self.assertIn(tf2.files_id, template_files._d)
     del tf2.files
     self.assertNotIn(tf2.files_id, template_files._d)
Ejemplo n.º 3
0
 def test_cache_miss(self):
     tf1 = template_files.TemplateFiles(template_files_1)
     tf1.store()
     # As this is the only reference to the value in _d, deleting
     # t1.files will cause the value to get removed from _d (due to
     # it being a WeakValueDictionary.
     del tf1.files
     self.assertNotIn(tf1.files_id, template_files._d)
     # this will cause the cache refresh
     self.assertEqual(template_files_1['template file 1'],
                      tf1['template file 1'])
     self.assertEqual(template_files_1, template_files._d[tf1.files_id])
Ejemplo n.º 4
0
 def files(self, files):
     self._template_files = template_files.TemplateFiles(files)