소스 검색

added test for not caching the Transformer

remotes/origin/gm/2021-09-23T00Z/github.com--lark-parser-lark/master
MegaIng 3 년 전
부모
커밋
1ee00c0e84
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. +6
    -1
      tests/test_cache.py

+ 6
- 1
tests/test_cache.py 파일 보기

@@ -52,6 +52,9 @@ class InlineTestT(Transformer):
def NUM(self, token):
return int(token)

def __reduce__(self):
raise TypeError("This Transformer should not be pickled.")


def append_zero(t):
return t.update(value=t.value + '0')
@@ -107,6 +110,8 @@ class TestCache(TestCase):
def test_inline(self):
# Test inline transformer (tree-less) & lexer_callbacks
# Note: the Transformer should not be saved to the file,
# and is made unpickable to check for that
g = """
start: add+
add: NUM "+" NUM
@@ -134,7 +139,7 @@ class TestCache(TestCase):
assert len(self.mock_fs.files) == 1
res = parser.parse("ab")
self.assertEqual(res, Tree('startab', [Tree('expr', ['a', 'b'])]))




불러오는 중...
취소
저장