diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-03-02 21:39:27 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-03-02 21:39:27 +0100 |
commit | c6757f642f4d73e0ffa530aac986d33aa632c04d (patch) | |
tree | 57f933cf9229ce3084442c1511caa90b71ebf32e | |
parent | dc7f1e81fb00fba428234944ae3d499a56c7083f (diff) | |
download | weechat-c6757f642f4d73e0ffa530aac986d33aa632c04d.zip |
tests: fix generation of test scripts with Python 3.8
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rwxr-xr-x | tests/scripts/python/unparse.py | 39 |
2 files changed, 40 insertions, 0 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 0bb37c90b..0189c069b 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -45,6 +45,7 @@ Bug fixes:: Tests:: + * scripts: fix generation of test scripts with Python 3.8 * unit: add tests on function secure_derive_key * unit: add tests on functions util_get_time_diff and util_file_get_content diff --git a/tests/scripts/python/unparse.py b/tests/scripts/python/unparse.py index 115cd668e..52dd9a4e0 100755 --- a/tests/scripts/python/unparse.py +++ b/tests/scripts/python/unparse.py @@ -200,6 +200,10 @@ class UnparsePython(object): comparator, ) + def _ast_constant(self, node): + """Add an AST Constant in output.""" + self.add(repr(node.s)) + def _ast_dict(self, node): """Add an AST Dict in output.""" self.add( @@ -267,6 +271,7 @@ class UnparsePython(object): def _ast_num(self, node): """Add an AST Num in output.""" + # note: deprecated since Python 3.8, replaced by ast.Constant self.add(repr(node.n)) def _ast_pass(self, node): # pylint: disable=unused-argument @@ -281,6 +286,7 @@ class UnparsePython(object): def _ast_str(self, node): """Add an AST Str in output.""" + # note: deprecated since Python 3.8, replaced by ast.Constant self.add(repr(node.s)) def _ast_tuple(self, node): @@ -378,6 +384,13 @@ class UnparsePerl(UnparsePython): comparator, ) + def _ast_constant(self, node): + """Add an AST Constant in output.""" + if isinstance(node.value, str): + self.add('"%s"' % node.s.replace('$', '\\$').replace('@', '\\@')) + else: + self.add(repr(node.s)) + def _ast_dict(self, node): """Add an AST Dict in output.""" self.add( @@ -471,6 +484,7 @@ class UnparsePerl(UnparsePython): def _ast_str(self, node): """Add an AST Str in output.""" + # note: deprecated since Python 3.8, replaced by ast.Constant self.add('"%s"' % node.s.replace('$', '\\$').replace('@', '\\@')) @@ -549,6 +563,7 @@ class UnparseRuby(UnparsePython): def _ast_str(self, node): """Add an AST Str in output.""" + # note: deprecated since Python 3.8, replaced by ast.Constant self.add('"%s"' % node.s) @@ -731,6 +746,13 @@ class UnparseTcl(UnparsePython): self.add('}]') self.prefix(None) + def _ast_constant(self, node): + """Add an AST Constant in output.""" + if isinstance(node.value, str): + self.add('"%s"' % node.s.replace('$', '\\$')) + else: + self.add(repr(node.s)) + def _ast_dict(self, node): """Add an AST Dict in output.""" self.add( @@ -799,6 +821,7 @@ class UnparseTcl(UnparsePython): def _ast_str(self, node): """Add an AST Str in output.""" + # note: deprecated since Python 3.8, replaced by ast.Constant self.add('"%s"' % node.s.replace('$', '\\$')) @@ -895,6 +918,13 @@ class UnparseGuile(UnparsePython): ')', ) + def _ast_constant(self, node): + """Add an AST Constant in output.""" + if isinstance(node.s, str): + self.add('"%s"' % node.s) + else: + self.add(repr(node.s)) + def _ast_dict(self, node): """Add an AST Dict in output.""" self.add( @@ -977,6 +1007,7 @@ class UnparseGuile(UnparsePython): def _ast_str(self, node): """Add an AST Str in output.""" + # note: deprecated since Python 3.8, replaced by ast.Constant self.add('"%s"' % node.s) @@ -1099,6 +1130,13 @@ class UnparsePhp(UnparsePython): ')', ) + def _ast_constant(self, node): + """Add an AST Constant in output.""" + if isinstance(node.s, str): + self.add('"%s"' % node.s.replace('$', '\\$')) + else: + self.add(repr(node.s)) + def _ast_dict(self, node): """Add an AST Dict in output.""" self.add( @@ -1184,6 +1222,7 @@ class UnparsePhp(UnparsePython): def _ast_str(self, node): """Add an AST Str in output.""" + # note: deprecated since Python 3.8, replaced by ast.Constant self.add('"%s"' % node.s.replace('$', '\\$')) |