[testlib] fake session can be given a vreg
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 11 May 2011 09:38:44 +0200
changeset 7360 dbff01dd3c3c
parent 7359 40490b9e0a6e
child 7361 6baa4f430c9b
[testlib] fake session can be given a vreg
devtools/fake.py
--- a/devtools/fake.py	Tue May 10 18:53:30 2011 +0200
+++ b/devtools/fake.py	Wed May 11 09:38:44 2011 +0200
@@ -139,9 +139,13 @@
 
 class FakeSession(RequestSessionBase):
 
-    def __init__(self, repo=None, user=None):
+    def __init__(self, repo=None, user=None, vreg=None):
         self.repo = repo
-        self.vreg = getattr(self.repo, 'vreg', CubicWebVRegistry(FakeConfig(), initlog=False))
+        if vreg is None:
+            vreg = getattr(self.repo, 'vreg', None)
+        if vreg is None:
+            vreg = CubicWebVRegistry(FakeConfig(), initlog=False)
+        self.vreg = vreg
         self.pool = FakePool()
         self.user = user or FakeUser()
         self.is_internal_session = False