Skip to content

Get rid of expected failures in tokenizer tests #283

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

Merged
merged 2 commits into from
May 6, 2020
Merged
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: 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