From 9ca5a14504dae9bf317c671f30d9f56fecd8a844 Mon Sep 17 00:00:00 2001 From: Liuyang Wan Date: Sun, 14 Jun 2020 14:31:14 +0800 Subject: [PATCH] Fix various py26 unit test failures --- .gitignore | 3 +++ src/libfuturize/fixes/fix_division_safe.py | 7 ++++++- tests/test_future/test_futurize.py | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1b142a7a..3b7bce98 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ nosetests.xml # PyCharm .idea + +# Generated test file +mytempfile.py diff --git a/src/libfuturize/fixes/fix_division_safe.py b/src/libfuturize/fixes/fix_division_safe.py index 3d5909cc..65c8c1da 100644 --- a/src/libfuturize/fixes/fix_division_safe.py +++ b/src/libfuturize/fixes/fix_division_safe.py @@ -92,7 +92,12 @@ def match(self, node): else: children.append(child.clone()) if matched: - return Node(node.type, children, fixers_applied=node.fixers_applied) + # In Python 2.6, `Node` does not have the fixers_applied attribute + # https://github.com/python/cpython/blob/8493c0cd66cfc181ac1517268a74f077e9998701/Lib/lib2to3/pytree.py#L235 + if hasattr(Node, "fixers_applied"): + return Node(node.type, children, fixers_applied=node.fixers_applied) + else: + return Node(node.type, children) return False diff --git a/tests/test_future/test_futurize.py b/tests/test_future/test_futurize.py index 0d7c42de..c3696a54 100644 --- a/tests/test_future/test_futurize.py +++ b/tests/test_future/test_futurize.py @@ -436,6 +436,7 @@ def test_import_builtins(self): """ self.convert_check(before, after, ignore_imports=False, run=False) + @expectedFailurePY26 def test_input_without_import(self): before = """ a = input() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy