Commits

Peter Sagerson  committed 69ff256

Raise ldap.FILTER_ERROR instead of ParserError.

Fixes #3.

  • Participants
  • Parent commits 61fb763

Comments (0)

Files changed (2)

File src/mockldap/filter.py

 Simple filter expression parser based on funcparserlib.
 """
 from functools import partial
+import ldap
 import re
 
 from funcparserlib.parser import (a, skip, oneplus, finished,
                                   with_forward_decls, NoParseError)
 
 
-class ParserError(Exception):
-    pass
-
-
 class UnsupportedOp(Exception):
     pass
 
         match = self.TEST_RE.match(self.content)
 
         if match is None:
-            raise ParserError(u"Failed to parse filter item '%s' at pos %d" % (self.content, self.start))
+            raise ldap.FILTER_ERROR(u"Failed to parse filter item '%s' at pos %d" % (self.content, self.start))
 
         self.attr, self.op, self.value = match.groups()
 
     try:
         return ldap_filter.parse(tokenize(filterstr))
     except NoParseError, e:
-        raise ParserError(e)
+        raise ldap.FILTER_ERROR(e)
 
 
 #

File src/mockldap/tests.py

     passlib = None
 
 from . import MockLdap
-from .filter import ParserError
 from .recording import SeedRequired
 
 
         self.assertEqual(results, [alice])
 
     def test_search_s_unparsable_filterstr(self):
-        with self.assertRaises(ParserError):
+        with self.assertRaises(ldap.FILTER_ERROR):
             self.ldapobj.search_s("ou=example,o=test", ldap.SCOPE_ONELEVEL,
                                   'invalid=*')
 
     def test_search_s_unparsable_filterstr_test(self):
-        with self.assertRaises(ParserError):
+        with self.assertRaises(ldap.FILTER_ERROR):
             self.ldapobj.search_s("ou=example,o=test", ldap.SCOPE_ONELEVEL,
                                   '(invalid=)')