diff --git a/Tests/t_bind.py b/Tests/t_bind.py index 6e9a61c..3e2b67f 100644 --- a/Tests/t_bind.py +++ b/Tests/t_bind.py @@ -9,9 +9,15 @@ PY2 = False text_type = str -import ldap, unittest -from slapdtest import SlapdTestCase +import os +import unittest + +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' + +import ldap from ldap.ldapobject import LDAPObject +from slapdtest import SlapdTestCase class TestBinds(SlapdTestCase): diff --git a/Tests/t_cext.py b/Tests/t_cext.py index d8233dc..af26706 100644 --- a/Tests/t_cext.py +++ b/Tests/t_cext.py @@ -10,13 +10,12 @@ import os import unittest -from slapdtest import SlapdTestCase, requires_tls - # Switch off processing .ldaprc or ldap.conf before importing _ldap os.environ['LDAPNOINIT'] = '1' # import the plain C wrapper module import _ldap +from slapdtest import SlapdTestCase, requires_tls class TestLdapCExtension(SlapdTestCase): diff --git a/Tests/t_cidict.py b/Tests/t_cidict.py index 00d0726..8e5d8d6 100644 --- a/Tests/t_cidict.py +++ b/Tests/t_cidict.py @@ -5,11 +5,13 @@ See https://www.python-ldap.org/ for details. """ -# from Python's standard lib +import os import unittest -# from python-ldap -import ldap, ldap.cidict +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' +import ldap +import ldap.cidict class TestCidict(unittest.TestCase): diff --git a/Tests/t_edit.py b/Tests/t_edit.py index 0012c9c..a5b3f65 100644 --- a/Tests/t_edit.py +++ b/Tests/t_edit.py @@ -9,10 +9,15 @@ PY2 = False text_type = str -import ldap, unittest -from slapdtest import SlapdTestCase +import os +import unittest + +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' +import ldap from ldap.ldapobject import LDAPObject +from slapdtest import SlapdTestCase class EditionTests(SlapdTestCase): diff --git a/Tests/t_ldap_controls_libldap.py b/Tests/t_ldap_controls_libldap.py index 229935e..d397861 100644 --- a/Tests/t_ldap_controls_libldap.py +++ b/Tests/t_ldap_controls_libldap.py @@ -4,7 +4,6 @@ # Switch off processing .ldaprc or ldap.conf before importing _ldap os.environ['LDAPNOINIT'] = '1' -import ldap from ldap.controls import pagedresults from ldap.controls import libldap diff --git a/Tests/t_ldap_dn.py b/Tests/t_ldap_dn.py index 459c1dc..4b4dd31 100644 --- a/Tests/t_ldap_dn.py +++ b/Tests/t_ldap_dn.py @@ -8,9 +8,11 @@ from __future__ import unicode_literals # from Python's standard lib +import os import unittest -# from python-ldap +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' import ldap.dn diff --git a/Tests/t_ldap_filter.py b/Tests/t_ldap_filter.py index 5eda05d..da96446 100644 --- a/Tests/t_ldap_filter.py +++ b/Tests/t_ldap_filter.py @@ -5,10 +5,12 @@ See https://www.python-ldap.org/ for details. """ -# from Python's standard lib +import os import unittest -# from python-ldap +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' + from ldap.filter import escape_filter_chars diff --git a/Tests/t_ldap_functions.py b/Tests/t_ldap_functions.py index cdd2ffb..45931da 100644 --- a/Tests/t_ldap_functions.py +++ b/Tests/t_ldap_functions.py @@ -5,10 +5,12 @@ See https://www.python-ldap.org/ for details. """ -# from Python's standard lib +import os import unittest -# from python-ldap +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' + import ldap from ldap.dn import escape_dn_chars from ldap.filter import escape_filter_chars diff --git a/Tests/t_ldap_modlist.py b/Tests/t_ldap_modlist.py index a206cde..db248b7 100644 --- a/Tests/t_ldap_modlist.py +++ b/Tests/t_ldap_modlist.py @@ -5,12 +5,16 @@ See https://www.python-ldap.org/ for details. """ +import os import unittest -import ldap +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' +import ldap from ldap.modlist import addModlist,modifyModlist + class TestModlist(unittest.TestCase): addModlist_tests = [ diff --git a/Tests/t_ldap_options.py b/Tests/t_ldap_options.py index a681a9b..ffc2451 100644 --- a/Tests/t_ldap_options.py +++ b/Tests/t_ldap_options.py @@ -4,12 +4,14 @@ # Switch off processing .ldaprc or ldap.conf before importing _ldap os.environ['LDAPNOINIT'] = '1' +from slapdtest import SlapdTestCase, requires_tls + import ldap from ldap.controls import RequestControlTuples from ldap.controls.pagedresults import SimplePagedResultsControl from ldap.controls.openldap import SearchNoOpControl from ldap.ldapobject import SimpleLDAPObject -from slapdtest import SlapdTestCase, requires_tls + SENTINEL = object() diff --git a/Tests/t_ldap_sasl.py b/Tests/t_ldap_sasl.py index d104468..e60ac12 100644 --- a/Tests/t_ldap_sasl.py +++ b/Tests/t_ldap_sasl.py @@ -5,7 +5,6 @@ See https://www.python-ldap.org/ for details. """ import os -import socket import unittest # Switch off processing .ldaprc or ldap.conf before importing _ldap diff --git a/Tests/t_ldap_schema_tokenizer.py b/Tests/t_ldap_schema_tokenizer.py index d676e8a..c858177 100644 --- a/Tests/t_ldap_schema_tokenizer.py +++ b/Tests/t_ldap_schema_tokenizer.py @@ -5,8 +5,12 @@ See https://www.python-ldap.org/ for details. """ +import os import unittest +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' + import ldap.schema # basic test cases diff --git a/Tests/t_ldap_syncrepl.py b/Tests/t_ldap_syncrepl.py index 71f240c..73ba1fb 100644 --- a/Tests/t_ldap_syncrepl.py +++ b/Tests/t_ldap_syncrepl.py @@ -16,8 +16,6 @@ else: PY2 = False -from slapdtest import SlapdObject, SlapdTestCase - # Switch off processing .ldaprc or ldap.conf before importing _ldap os.environ['LDAPNOINIT'] = '1' @@ -25,6 +23,8 @@ from ldap.ldapobject import SimpleLDAPObject from ldap.syncrepl import SyncreplConsumer +from slapdtest import SlapdObject, SlapdTestCase + # a template string for generating simple slapd.conf file SLAPD_CONF_PROVIDER_TEMPLATE = r""" serverID %(serverid)s diff --git a/Tests/t_ldapobject.py b/Tests/t_ldapobject.py index 2c8ce75..b57ecf1 100644 --- a/Tests/t_ldapobject.py +++ b/Tests/t_ldapobject.py @@ -22,8 +22,6 @@ import unittest import warnings import pickle -from slapdtest import SlapdTestCase -from slapdtest import requires_ldapi, requires_sasl, requires_tls # Switch off processing .ldaprc or ldap.conf before importing _ldap os.environ['LDAPNOINIT'] = '1' @@ -31,6 +29,10 @@ import ldap from ldap.ldapobject import SimpleLDAPObject, ReconnectLDAPObject +from slapdtest import SlapdTestCase +from slapdtest import requires_ldapi, requires_sasl, requires_tls + + LDIF_TEMPLATE = """dn: %(suffix)s objectClass: dcObject objectClass: organization diff --git a/Tests/t_ldapurl.py b/Tests/t_ldapurl.py index 2be03f6..c4a813d 100644 --- a/Tests/t_ldapurl.py +++ b/Tests/t_ldapurl.py @@ -7,7 +7,12 @@ from __future__ import unicode_literals +import os import unittest + +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' + from ldap.compat import quote import ldapurl diff --git a/Tests/t_ldif.py b/Tests/t_ldif.py index adf0d26..4f181df 100644 --- a/Tests/t_ldif.py +++ b/Tests/t_ldif.py @@ -7,16 +7,18 @@ from __future__ import unicode_literals -# from Python's standard lib -import unittest +import os import textwrap +import unittest try: from StringIO import StringIO except ImportError: from io import StringIO -# from python-ldap +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' + import ldif diff --git a/Tests/t_untested_mods.py b/Tests/t_untested_mods.py index 7f0f30d..5e726a6 100644 --- a/Tests/t_untested_mods.py +++ b/Tests/t_untested_mods.py @@ -1,5 +1,10 @@ # modules without any tests +import os + +# Switch off processing .ldaprc or ldap.conf before importing _ldap +os.environ['LDAPNOINIT'] = '1' + import ldap.controls.deref import ldap.controls.openldap import ldap.controls.ppolicy