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

Tests: Small fixes #1122

Merged
merged 1 commit into from
Mar 1, 2022
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
7 changes: 6 additions & 1 deletion tests/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import

import logging
from unittest import TestCase, main
from unittest import TestCase, main, skipIf

from lark import Lark, Tree, Transformer
from lark.lexer import Lexer, Token
Expand All @@ -12,6 +12,10 @@
except ImportError:
from io import BytesIO as StringIO

try:
import regex
except ImportError:
regex = None

class MockFile(StringIO):
def close(self):
Expand Down Expand Up @@ -141,6 +145,7 @@ def test_imports(self):
res = parser.parse("ab")
self.assertEqual(res, Tree('startab', [Tree('expr', ['a', 'b'])]))

@skipIf(regex is None, "'regex' lib not installed")
def test_recursive_pattern(self):
g = """
start: recursive+
Expand Down
4 changes: 2 additions & 2 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2461,7 +2461,7 @@ def match_error(s):
self.assertEqual( match_error("ebc"), 2 )


@unittest.skipIf(not regex or sys.version_info[0] == 2, 'Unicode and Python 2 do not place nicely together.')
@unittest.skipIf(not regex, "regex not installed")
def test_unicode_class(self):
"Tests that character classes from the `regex` module work correctly."
g = _Lark(r"""?start: NAME
Expand All @@ -2471,7 +2471,7 @@ def test_unicode_class(self):

self.assertEqual(g.parse('வணக்கம்'), 'வணக்கம்')

@unittest.skipIf(not regex or sys.version_info[0] == 2, 'Unicode and Python 2 do not place nicely together.')
@unittest.skipIf(not regex, "regex not installed")
def test_unicode_word(self):
"Tests that a persistent bug in the `re` module works when `regex` is enabled."
g = _Lark(r"""?start: NAME
Expand Down