diff --git a/setup.py b/setup.py index 50ed837..234f96e 100644 --- a/setup.py +++ b/setup.py @@ -12,13 +12,15 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Topic :: System :: Systems Administration :: Authentication/Directory', 'Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP', ] setup( name="simpleldap", - version="0.8", + version="0.9", description="A module that makes simple LDAP usage simple.", long_description=open('README.rst').read(), keywords="ldap simple simpleldap", @@ -28,5 +30,5 @@ license="MIT", packages=["simpleldap"], install_requires=["python-ldap"], - tests_require=["tox", "pytest", "pep8", "python-ldap"], + tests_require=["tox", "pytest", "pycodestye", "python-ldap", "six"], ) diff --git a/simpleldap/__init__.py b/simpleldap/__init__.py index 99500b6..3854c2e 100644 --- a/simpleldap/__init__.py +++ b/simpleldap/__init__.py @@ -50,7 +50,7 @@ def __init__(self, result): self.dn, self.attributes = result # XXX: quick and dirty, should really proxy straight to the existing # self.attributes dict. - for attribute, values in self.attributes.iteritems(): + for attribute, values in self.attributes.items(): # Make the entire list of values for each LDAP attribute # accessible through a dictionary mapping. self[attribute] = values @@ -168,7 +168,7 @@ def __init__(self, hostname='localhost', port=None, dn='', password='', else: self.connection = ldap.initialize(uri) if options: - for name, value in options.iteritems(): + for name, value in options.items(): self.connection.set_option(getattr(ldap, name), value) if encryption == 'tls': self.connection.start_tls_s() diff --git a/simpleldap/cidict.py b/simpleldap/cidict.py index 19cf374..0d0268f 100644 --- a/simpleldap/cidict.py +++ b/simpleldap/cidict.py @@ -32,7 +32,7 @@ def update(self, dict): self[key] = dict[key] def has_key(self, key): - return super(cidict, self).has_key(key.lower()) + return key.lower() in super(cidict, self).keys() __contains__ = has_key diff --git a/tests/tests.py b/tests/tests.py index 2f4d119..78b809f 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -3,6 +3,7 @@ from unittest import TestCase import ldap +from six import StringIO import simpleldap @@ -25,14 +26,13 @@ def test_connect(self): conn = simpleldap.Connection(hostname=host, port=port, encryption=method, require_cert=cert) - except Exception, e: + except Exception as e: self.fail("Got error connecting to %s %s %s %s: %s" % (host, port, method, cert, e)) else: conn.close() def test_initialize_kwargs(self): - from StringIO import StringIO output = StringIO() initialize_kwargs = {'trace_file': output, 'trace_level': 0} conn = simpleldap.Connection('ldap.utexas.edu', @@ -107,7 +107,7 @@ def test_get(self): obj = conn.get('cn=External Anonymous', base_dn='ou=Groups,dc=ucdavis,dc=edu') self.assertTrue(isinstance(obj, conn.result_item_class)) - self.assertEqual(obj['cn'], ['External Anonymous']) + self.assertEqual(obj['cn'], [b'External Anonymous']) self.assertRaises(simpleldap.ObjectNotFound, conn.get, 'cn=Does not exist', diff --git a/tox.ini b/tox.ini index 102e8c7..2a7238d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,13 @@ [tox] -envlist = py26, py27 -indexserver = - pypi = http://pypi.python.org/simple +envlist = py26,py27,py36,py37 [testenv] deps= - :pypi:python-ldap - :pypi:pytest - :pypi:pep8 + python-ldap + pytest<5 + pycodestyle + six commands = py.test -v tests/tests.py tests/cidict.py - pep8 --ignore=W601 simpleldap + pycodestyle --ignore=W601 simpleldap