[pypy-svn] pypy default: Beautify a bit and indent code strings with the "if 1:" trick

amauryfa commits-noreply at bitbucket.org
Wed Jan 19 20:33:34 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r40952:a3fc0ba7bad0
Date: 2011-01-19 19:54 +0100
http://bitbucket.org/pypy/pypy/changeset/a3fc0ba7bad0/

Log:	Beautify a bit and indent code strings with the "if 1:" trick

diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py
--- a/pypy/interpreter/astcompiler/test/test_compiler.py
+++ b/pypy/interpreter/astcompiler/test/test_compiler.py
@@ -425,11 +425,12 @@
         decl = str(decl) + "\n"
         yield self.st, decl, 'x', (1, 2, 3, 4)
 
-        source = """def f(a):
-    del a
-    def x():
-        a
-"""
+        source = """if 1:
+        def f(a):
+            del a
+            def x():
+                a
+        """
         exc = py.test.raises(SyntaxError, self.run, source).value
         assert exc.msg == "Can't delete variable used in nested scopes: 'a'"
 
@@ -732,15 +733,16 @@
         yield self.st, "x = None; y = `x`", "y", "None"
 
     def test_deleting_attributes(self):
-        test = """class X():
-   x = 3
-del X.x
-try:
-    X.x
-except AttributeError:
-    pass
-else:
-    raise AssertionError("attribute not removed")"""
+        test = """if 1:
+        class X():
+           x = 3
+        del X.x
+        try:
+            X.x
+        except AttributeError:
+            pass
+        else:
+            raise AssertionError("attribute not removed")"""
         yield self.st, test, "X.__name__", "X"
 
 
@@ -760,10 +762,12 @@
         assert "0 ('hi')" not in output.getvalue()
 
     def test_print_to(self):
-         exec """from StringIO import StringIO
-s = StringIO()
-print >> s, "hi", "lovely!"
-assert s.getvalue() == "hi lovely!\\n"
-s = StringIO()
-print >> s, "hi", "lovely!",
-assert s.getvalue() == "hi lovely!\"""" in {}
+         exec """if 1:
+         from StringIO import StringIO
+         s = StringIO()
+         print >> s, "hi", "lovely!"
+         assert s.getvalue() == "hi lovely!\\n"
+         s = StringIO()
+         print >> s, "hi", "lovely!",
+         assert s.getvalue() == "hi lovely!"
+         """ in {}


More information about the Pypy-commit mailing list