changeset 3661:2d5a325ae247

ldap tests: rename base class so py.test doesn't find it, skip tests if slapd is not started
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 01 Jun 2008 21:44:00 +0200
parents b3354cf420ff
children 9901ffff5280
files MoinMoin/_tests/ldap_testbase.py MoinMoin/auth/_tests/test_ldap_login.py
diffstat 2 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/ldap_testbase.py	Sun Jun 01 20:12:04 2008 +0200
+++ b/MoinMoin/_tests/ldap_testbase.py	Sun Jun 01 21:44:00 2008 +0200
@@ -231,7 +231,7 @@
 try:
     import py.test
 
-    class LDAPTestBase:
+    class LDAPTstBase:
         """ Test base class for py.test based tests which need a LDAP server to talk to.
 
             Inherit your test class from this base class to test LDAP stuff.
--- a/MoinMoin/auth/_tests/test_ldap_login.py	Sun Jun 01 20:12:04 2008 +0200
+++ b/MoinMoin/auth/_tests/test_ldap_login.py	Sun Jun 01 21:44:00 2008 +0200
@@ -8,7 +8,7 @@
 
 import py.test
 
-from MoinMoin._tests.ldap_testbase import LDAPTestBase, LdapEnvironment, check_environ
+from MoinMoin._tests.ldap_testbase import LDAPTstBase, LdapEnvironment, check_environ, SLAPD_EXECUTABLE
 from MoinMoin._tests.ldap_testdata import *
 from MoinMoin._tests import nuke_user
 
@@ -20,7 +20,7 @@
 
 import ldap
 
-class TestSimpleLdap(LDAPTestBase):
+class TestSimpleLdap(LDAPTstBase):
     basedn = BASEDN
     rootdn = ROOTDN
     rootpw = ROOTPW
@@ -72,7 +72,7 @@
         assert u1.id != u2.id
 
 
-class TestBugDefaultPasswd(LDAPTestBase):
+class TestBugDefaultPasswd(LDAPTstBase):
     basedn = BASEDN
     rootdn = ROOTDN
     rootpw = ROOTPW
@@ -137,7 +137,10 @@
         for instance in range(2):
             ldap_env = LdapEnvironment(self.basedn, self.rootdn, self.rootpw, instance=instance)
             ldap_env.create_env(slapd_config=self.slapd_config)
-            ldap_env.start_slapd()
+            started = ldap_env.start_slapd()
+            if not started:
+                py.test.skip("Failed to start %s process, please see your syslog / log files"
+                             " (and check if stopping apparmor helps, in case you use it)." % SLAPD_EXECUTABLE)
             ldap_env.load_directory(ldif_content=self.ldif_content)
             self.ldap_envs.append(ldap_env)
 
@@ -174,7 +177,10 @@
         for instance in range(2):
             ldap_env = LdapEnvironment(self.basedn, self.rootdn, self.rootpw, instance=instance)
             ldap_env.create_env(slapd_config=self.slapd_config)
-            ldap_env.start_slapd()
+            started = ldap_env.start_slapd()
+            if not started:
+                py.test.skip("Failed to start %s process, please see your syslog / log files"
+                             " (and check if stopping apparmor helps, in case you use it)." % SLAPD_EXECUTABLE)
             ldap_env.load_directory(ldif_content=self.ldif_content)
             self.ldap_envs.append(ldap_env)