Przeglądaj źródła

[useradmin] The useradmin tests leak state across tests

This is a bit of a hack in order to get things working, but we should
put in the effort to make sure our tests are deterministic and clean
up their state between runs.
Erick Tryzelaar 11 lat temu
rodzic
commit
81f6b2f784
1 zmienionych plików z 6 dodań i 0 usunięć
  1. 6 0
      apps/useradmin/src/useradmin/tests.py

+ 6 - 0
apps/useradmin/src/useradmin/tests.py

@@ -734,6 +734,9 @@ class MockLdapConnection(object):
     self.ldap_cert = ldap_cert
 
 def test_get_connection_bind_password():
+  # Unfortunately our tests leak a cached test ldap connection across functions, so we need to clear it out.
+  useradmin.ldap_access.CACHED_LDAP_CONN = None
+
   # Monkey patch the LdapConnection class as we don't want to make a real connection.
   OriginalLdapConnection = useradmin.ldap_access.LdapConnection
   reset = [
@@ -760,6 +763,9 @@ def test_get_connection_bind_password():
       f()
 
 def test_get_connection_bind_password_script():
+  # Unfortunately our tests leak a cached test ldap connection across functions, so we need to clear it out.
+  useradmin.ldap_access.CACHED_LDAP_CONN = None
+
   SCRIPT = '%s -c "print \'\\n password from script \\n\'"' % sys.executable
 
   # Monkey patch the LdapConnection class as we don't want to make a real connection.