diff --git a/sandbox/grist/test_codebuilder.py b/sandbox/grist/test_codebuilder.py index 27c6422d..534095f6 100644 --- a/sandbox/grist/test_codebuilder.py +++ b/sandbox/grist/test_codebuilder.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +import unittest + import codebuilder import six import test_engine @@ -195,6 +197,23 @@ return rec self.assertEqual(type(make_body("foo")), six.text_type) self.assertEqual(type(make_body(u"foo")), six.text_type) + @unittest.skipUnless(six.PY3, "Only Python 3 supports non-ascii variable names") + def test_make_formula_body_unicode_token_bug(self): + # Python < 3.12 has a bug in tokenizing certain unicode characters in variable names. + # This was worked around in https://github.com/gristlabs/asttokens/pull/82 + # Surprisingly this test passes either way, but keeping it as a potentially tricky case. + self.assertEqual( + make_body( + "℘℘··℘℘2=℘℘··℘℘2($foo+℘℘··℘℘2*℘℘··℘℘2+$bar)\n" + "℘℘··℘℘2=1+a℘℘··℘℘b+a℘℘··℘℘2b\n" + "℘℘··℘℘2==℘℘··℘℘2($foo+℘℘··℘℘2*℘℘··℘℘2+$bar)" + ), + ( + "℘℘··℘℘2=℘℘··℘℘2(rec.foo+℘℘··℘℘2*℘℘··℘℘2+rec.bar)\n" + "℘℘··℘℘2=1+a℘℘··℘℘b+a℘℘··℘℘2b\n" + "return ℘℘··℘℘2==℘℘··℘℘2(rec.foo+℘℘··℘℘2*℘℘··℘℘2+rec.bar)" + ), + ) def test_wrap_logical(self): self.assertEqual(make_body("IF($foo, $bar, $baz)"), diff --git a/sandbox/requirements3.txt b/sandbox/requirements3.txt index ed99cfdf..53acc46e 100644 --- a/sandbox/requirements3.txt +++ b/sandbox/requirements3.txt @@ -6,7 +6,7 @@ # astroid==2.14.2 # via -r core/sandbox/requirements3.in -asttokens==2.0.5 +asttokens==2.2.1 # via # friendly-traceback # stack-data @@ -51,5 +51,5 @@ typing-extensions==4.4.0 # via astroid unittest-xml-reporting==2.0.0 # via -r core/sandbox/requirements3.in -wrapt==1.12.1 +wrapt==1.15.0 # via astroid