Permalink
Browse files

TST: f2py: rewrite strings to be easier to read

  • Loading branch information...
1 parent 4b500dd commit 7b3e6fa5c8eb92eeab20bfbb6f4298d97396e103 @pv pv committed Nov 17, 2012
Showing with 39 additions and 26 deletions.
  1. +28 −24 numpy/f2py/tests/test_callback.py
  2. +11 −2 numpy/f2py/tests/test_mixed.py
@@ -2,6 +2,7 @@
from numpy import array
import math
import util
+import textwrap
class TestF77Callback(util.F2PyTest):
code = """
@@ -40,30 +41,33 @@ def test_all(self):
@dec.slow
def test_docstring(self):
- assert_equal(self.module.t.__doc__,
- "a = t(fun,[fun_extra_args])\n"
- "\n"
- "Wrapper for ``t``.\n"
- "\n"
- "Parameters\n"
- "----------\n"
- "fun : call-back function\n"
- "\n"
- "Other Parameters\n"
- "----------------\n"
- "fun_extra_args : input tuple, optional\n"
- " Default: ()\n"
- "\n"
- "Returns\n-------\n"
- "a : int\n"
- "\n"
- "Notes\n"
- "-----\n"
- "Call-back functions::\n"
- "\n"
- " def fun(): return a\n"
- " Return objects:\n"
- " a : int\n")
+ expected = """
+ a = t(fun,[fun_extra_args])
+
+ Wrapper for ``t``.
+
+ Parameters
+ ----------
+ fun : call-back function
+
+ Other Parameters
+ ----------------
+ fun_extra_args : input tuple, optional
+ Default: ()
+
+ Returns
+ -------
+ a : int
+
+ Notes
+ -----
+ Call-back functions::
+
+ def fun(): return a
+ Return objects:
+ a : int
+ """
+ assert_equal(self.module.t.__doc__, textwrap.dedent(expected).lstrip())
def check_function(self, name):
t = getattr(self.module, name)
@@ -5,6 +5,7 @@
from numpy import array
import util
+import textwrap
def _path(*a):
return os.path.join(*((os.path.dirname(__file__),) + a))
@@ -22,8 +23,16 @@ def test_all(self):
@dec.slow
def test_docstring(self):
- assert_equal(self.module.bar11.__doc__,
- "a = bar11()\n\nWrapper for ``bar11``.\n\nReturns\n-------\na : int\n")
+ expected = """
+ a = bar11()
+
+ Wrapper for ``bar11``.
+
+ Returns
+ -------
+ a : int
+ """
+ assert_equal(self.module.bar11.__doc__, textwrap.dedent(expected).lstrip())
if __name__ == "__main__":
import nose

0 comments on commit 7b3e6fa

Please sign in to comment.