[Python-checkins] r54453 - sandbox/trunk/2to3/tests/support.py

collin.winter python-checkins at python.org
Tue Mar 20 04:32:29 CET 2007


Author: collin.winter
Date: Tue Mar 20 04:32:25 2007
New Revision: 54453

Modified:
   sandbox/trunk/2to3/tests/support.py
Log:
Reimplement tests.support.reformat().

Modified: sandbox/trunk/2to3/tests/support.py
==============================================================================
--- sandbox/trunk/2to3/tests/support.py	(original)
+++ sandbox/trunk/2to3/tests/support.py	Tue Mar 20 04:32:25 2007
@@ -5,6 +5,7 @@
 import sys
 import os.path
 import re
+from textwrap import dedent
 
 TestCase = unittest.TestCase
 
@@ -24,12 +25,5 @@
     parent_dir = os.path.split(sys.path[0])[0]
     sys.path = [parent_dir] + sys.path
 
-
-skip_whitespace = re.compile(r"""\S""")
 def reformat(string):
-    indent = re.search(skip_whitespace, string).start()
-    if indent == 0:
-        code = string
-    else:
-        code = "\n".join([line[indent-1:] for line in string.split("\n")[1:]])
-    return code + "\n\n"
+    return dedent(string) + "\n\n"


More information about the Python-checkins mailing list