From 1ee00c0e84d483f8dbd229cfd4c3db22d9f3c85d Mon Sep 17 00:00:00 2001 From: MegaIng Date: Sun, 19 Sep 2021 14:50:55 +0200 Subject: [PATCH] added test for not caching the Transformer --- tests/test_cache.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_cache.py b/tests/test_cache.py index 9f71552..5778632 100644 --- a/tests/test_cache.py +++ b/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'])])) - +