From 44682fb9cd3a539317cdf0a8d9deab326b2c6061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 15 Nov 2020 18:50:47 +0100 Subject: [PATCH] Unify PYSON string format between all clients issue9723 review328481002 --- CHANGELOG | 1 + trytond/pyson.py | 2 ++ trytond/tests/test_pyson.py | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 8108c49fe9..c5b6eebeb1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Unify PYSON string format * Forbid all white spaces except space in Char field Version 5.8.0 - 2020-11-02 diff --git a/trytond/pyson.py b/trytond/pyson.py index 23b09cc04c..d79fefb876 100644 --- a/trytond/pyson.py +++ b/trytond/pyson.py @@ -769,4 +769,6 @@ CONTEXT = { 'TimeDelta': TimeDelta, 'Len': Len, 'Id': Id, + 'true': True, + 'false': False, } diff --git a/trytond/tests/test_pyson.py b/trytond/tests/test_pyson.py index 66aae94eb5..bc8102312f 100644 --- a/trytond/tests/test_pyson.py +++ b/trytond/tests/test_pyson.py @@ -838,6 +838,14 @@ class PYSONTestCase(unittest.TestCase): ]: self.assertEqual(pyson.PYSONDecoder(ctx).decode(eval), result) + def test_eval_true(self): + "Test PYSON.eval JS true" + self.assertEqual(eval('true', pyson.CONTEXT), True) + + def test_eval_false(self): + "Test PYSON.eval JS false" + self.assertEqual(eval('false', pyson.CONTEXT), False) + def suite(): return unittest.TestLoader().loadTestsFromTestCase(PYSONTestCase)