Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid dependency on ldap by optionally faking the exceptions #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion fakeldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@
import logging
import types
from collections import defaultdict
import ldap

try:
import ldap
except ImportError:
class ldap(object):
class LDAPError(Exception): pass
class INVALID_CREDENTIALS(LDAPError): pass
class NO_SUCH_OBJECT(LDAPError): pass
class ALREADY_EXISTS(LDAPError): pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here explaining the motivation from the PR description? I think it'll be helpful for future folks reading the code to not need to spelink.



logger = logging.getLogger(__name__)
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()

extra = {}
requirements = ['pyldap'],
tests_require = ['nose', 'Mock', 'coverage', 'unittest2', 'pyldap']
tests_require = ['nose', 'Mock', 'coverage', 'unittest2', 'python-ldap']

setup(
name = "fakeldap",
version = __version__,
#packages = find_packages('fakeldap'),
#include_package_data=True,
py_modules = ['fakeldap'],
install_requires = requirements,

tests_require=tests_require,
setup_requires='nose',
Expand Down
3 changes: 1 addition & 2 deletions tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from nose.tools import *
from fakeldap import MockLDAP
import ldap
from fakeldap import MockLDAP, ldap

import unittest

Expand Down