diff --git a/tests/test_reconstructor.py b/tests/test_reconstructor.py index 45a6656..f132312 100644 --- a/tests/test_reconstructor.py +++ b/tests/test_reconstructor.py @@ -1,19 +1,22 @@ # coding=utf-8 import json +import sys import unittest from unittest import TestCase + from lark import Lark from lark.reconstruct import Reconstructor - common = """ %import common (WS_INLINE, NUMBER, WORD) %ignore WS_INLINE """ + def _remove_ws(s): - return s.replace(' ', '').replace('\n','') + return s.replace(' ', '').replace('\n', '') + class TestReconstructor(TestCase): @@ -24,7 +27,6 @@ class TestReconstructor(TestCase): self.assertEqual(_remove_ws(code), _remove_ws(new)) def test_starred_rule(self): - g = """ start: item* item: NL @@ -40,7 +42,6 @@ class TestReconstructor(TestCase): self.assert_reconstruct(g, code) def test_starred_group(self): - g = """ start: (rule | NL)* rule: WORD ":" NUMBER @@ -54,7 +55,6 @@ class TestReconstructor(TestCase): self.assert_reconstruct(g, code) def test_alias(self): - g = """ start: line* line: NL @@ -142,6 +142,7 @@ class TestReconstructor(TestCase): new_json = Reconstructor(json_parser).reconstruct(tree) self.assertEqual(json.loads(new_json), json.loads(test_json)) + @unittest.skipIf(sys.version_info < (3, 0), "Python 2 does not play well with Unicode.") def test_switch_grammar_unicode_terminal(self): """ This test checks that a parse tree built with a grammar containing only ascii characters can be reconstructed @@ -179,6 +180,5 @@ class TestReconstructor(TestCase): assert l2.parse(code2) == tree - if __name__ == '__main__': unittest.main()