dabeaz / ply

Python Lex-Yacc
http://www.dabeaz.com/ply/index.html
2.76k stars 460 forks source link

Unit tests when using the regex module instead of re fails #24

Closed crogre closed 9 years ago

crogre commented 11 years ago

I tried replacing "import re" with "import regex as re" in lex.py and yacc.py for good measure (I saw that regex is slotted for python 3.4 and that that module supports concurrency) but got two errors in the lex unit tests (python testlex.py):

FAIL: test_lex_re1 (main.LexErrorWarningTests)

Traceback (most recent call last): File "testlex.py", line 143, in test_lex_re1 "Invalid regular expression for rule 't_NUMBER'. unbalanced parenthesis\n")) AssertionError: False is not true

FAIL: test_lex_re3 (main.LexErrorWarningTests)

Traceback (most recent call last): File "testlex.py", line 155, in test_lex_re3 "Invalid regular expression for rule 't_POUND'. unbalanced parenthesis\n" AssertionError: False is not true

According to the maintainer of regex this is because the exception messages are different - regex throws "missing )" instead of "unbalanced parenthesis".

Is it correct to rely on the message strings for the unit tests?

dabeaz commented 11 years ago

Unit tests are checking for specific errors. Will revisit in future. Leaving issue open for now.

dabeaz commented 9 years ago

As far as I know, the status of "regex" in the standard library is pretty unclear at this point. Going to close the issue for now, but will revisit should its status change.