[Zope-CVS] SVN: ldapadapter/trunk/tests/test_ldapadapter.py Better ldap override for tests.

Florent Guillaume fg at nuxeo.com
Sat Oct 9 08:54:01 EDT 2004


Log message for revision 27822:
  Better ldap override for tests.
  


Changed:
  U   ldapadapter/trunk/tests/test_ldapadapter.py


-=-
Modified: ldapadapter/trunk/tests/test_ldapadapter.py
===================================================================
--- ldapadapter/trunk/tests/test_ldapadapter.py	2004-10-09 12:48:59 UTC (rev 27821)
+++ ldapadapter/trunk/tests/test_ldapadapter.py	2004-10-09 12:54:01 UTC (rev 27822)
@@ -26,16 +26,26 @@
 def setUp(test):
     import fakeldap
     if sys.modules.has_key('_ldap'):
-        test.old_ldap = sys.modules['_ldap']
+        test.old_uldap = sys.modules['_ldap']
         del sys.modules['_ldap']
     else:
+        test.old_uldap = None
+    if sys.modules.has_key('ldap'):
+        test.old_ldap = sys.modules['ldap']
+        del sys.modules['ldap']
+    else:
         test.old_ldap = None
-    sys.modules['_ldap'] = fakeldap
+    sys.modules['ldap'] = fakeldap
+    import ldap
 
 def tearDown(test):
-    del sys.modules['_ldap']
+    del sys.modules['ldap']
+    if test.old_uldap is not None:
+        del sys.modules['_ldap']
+        sys.modules['_ldap'] = test.old_uldap
     if test.old_ldap is not None:
-        sys.modules['_ldap'] = test.old_ldap
+        sys.modules['ldap'] = test.old_ldap
+    import ldap
 
 def test_suite():
     return unittest.TestSuite((



More information about the Zope-CVS mailing list