server/test/unittest_storage.py
branchstable
changeset 5109 5cf83b9356d5
parent 5013 ad91f93bbb93
child 5131 88b5ca8da928
--- a/server/test/unittest_storage.py	Wed Mar 31 12:53:24 2010 +0200
+++ b/server/test/unittest_storage.py	Wed Mar 31 14:25:26 2010 +0200
@@ -6,6 +6,8 @@
 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
 """
 
+from __future__ import with_statement
+
 from logilab.common.testlib import unittest_main
 from cubicweb.devtools.testlib import CubicWebTC
 
@@ -93,14 +95,8 @@
         self.assertEquals(fspath.getvalue(), '/the/path')
 
     def test_source_storage_transparency(self):
-        self.vreg._loadedmods[__name__] = {}
-        self.vreg.register(DummyBeforeHook)
-        self.vreg.register(DummyAfterHook)
-        try:
+        with self.temporary_appobjects(DummyBeforeHook, DummyAfterHook):
             self.create_file()
-        finally:
-            self.vreg.unregister(DummyBeforeHook)
-            self.vreg.unregister(DummyAfterHook)
 
     def test_source_mapped_attribute_error_cases(self):
         ex = self.assertRaises(QueryError, self.execute,