summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/tests/test_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/lib2to3/tests/test_util.py')
-rw-r--r--Lib/lib2to3/tests/test_util.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/lib2to3/tests/test_util.py b/Lib/lib2to3/tests/test_util.py
index 6186b4f..0ab7537 100644
--- a/Lib/lib2to3/tests/test_util.py
+++ b/Lib/lib2to3/tests/test_util.py
@@ -575,3 +575,20 @@ class Test_touch_import(support.TestCase):
node = parse('bar()')
fixer_util.touch_import(None, "cgi", node)
self.assertEqual(str(node), 'import cgi\nbar()\n\n')
+
+class Test_find_indentation(support.TestCase):
+
+ def test_nothing(self):
+ fi = fixer_util.find_indentation
+ node = parse("node()")
+ self.assertEqual(fi(node), "")
+ node = parse("")
+ self.assertEqual(fi(node), "")
+
+ def test_simple(self):
+ fi = fixer_util.find_indentation
+ node = parse("def f():\n x()")
+ self.assertEqual(fi(node), "")
+ self.assertEqual(fi(node.children[0].children[4].children[2]), " ")
+ node = parse("def f():\n x()\n y()")
+ self.assertEqual(fi(node.children[0].children[4].children[4]), " ")