Skip to content

Commit

Permalink
Get rid of expected failures in tokenizer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondřej Kuzník authored and GitHub committed May 6, 2020
1 parent 8dd59ea commit 7e084ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 7 additions & 3 deletions Lib/ldap/schema/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
r"|" # or
r"([^'$()\s]+)" # string of length >= 1 without '$() or whitespace
r"|" # or
r"('.*?'(?!\w))" # any string or empty string surrounded by single quotes
# except if right quote is succeeded by alphanumeric char
r"('(?:[^'\\]|\\\\|\\.)*?'(?!\w))"
# any string or empty string surrounded by unescaped
# single quotes except if right quote is succeeded by
# alphanumeric char
r"|" # or
r"([^\s]+?)", # residue, all non-whitespace strings
).findall

UNESCAPE_PATTERN = re.compile(r"\\(.)")


def split_tokens(s):
"""
Expand All @@ -30,7 +34,7 @@ def split_tokens(s):
if unquoted:
parts.append(unquoted)
elif quoted:
parts.append(quoted[1:-1])
parts.append(UNESCAPE_PATTERN.sub(r'\1', quoted[1:-1]))
elif opar:
parens += 1
parts.append(opar)
Expand Down
6 changes: 2 additions & 4 deletions Tests/t_ldap_schema_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@

# broken schema of Oracle Internet Directory
TESTCASES_BROKEN_OID = (
("BLUBB DI 'BLU B B ER'MUST 'BLAH' ", ['BLUBB', 'DI', 'BLU B B ER', 'MUST', 'BLAH']),
("BLUBBER DI 'BLU'BB ER' DA 'BLAH' ", ["BLUBBER", "DI", "BLU'BB ER", "DA", "BLAH"]),
"BLUBB DI 'BLU B B ER'MUST 'BLAH' ", #['BLUBB', 'DI', 'BLU B B ER', 'MUST', 'BLAH']
"BLUBBER DI 'BLU'BB ER' DA 'BLAH' ", #["BLUBBER", "DI", "BLU'BB ER", "DA", "BLAH"]
)

# for quoted single quotes inside string values
Expand Down Expand Up @@ -104,14 +104,12 @@ def test_utf8(self):
"""
self._run_split_tokens_tests(TESTCASES_UTF8)

@unittest.expectedFailure
def test_broken_oid(self):
"""
run test cases specified in constant TESTCASES_BROKEN_OID
"""
self._run_failure_tests(TESTCASES_BROKEN_OID)

@unittest.expectedFailure
def test_escaped_quotes(self):
"""
run test cases specified in constant TESTCASES_ESCAPED_QUOTES
Expand Down

0 comments on commit 7e084ae

Please sign in to comment.