[pypy-commit] pypy py3k: Fix docstring-only test functions (a hack to test python3-only syntax)

amauryfa noreply at buildbot.pypy.org
Thu Feb 21 23:42:41 CET 2013


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r61572:01ed12fd958d
Date: 2013-02-21 23:41 +0100
http://bitbucket.org/pypy/pypy/changeset/01ed12fd958d/

Log:	Fix docstring-only test functions (a hack to test python3-only
	syntax)

diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py
--- a/pypy/tool/pytest/apptest.py
+++ b/pypy/tool/pytest/apptest.py
@@ -118,7 +118,11 @@
             defs.append("self.%s = %s\n" % (symbol, py3k_repr(value)))
     source = py.code.Source(target_)[1:]
     pyfile = udir.join('src.py')
-    target_name = target_.__name__
+    if isinstance(target_, str):
+        # Special case of a docstring; the function name is the first word.
+        target_name = target_.split('(', 1)[0]
+    else:
+        target_name = target_.__name__
     with pyfile.open('w') as f:
         f.write(helpers)
         f.write('\n'.join(defs))


More information about the pypy-commit mailing list