diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-08-28 09:39:56 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2019-04-10 23:35:46 -0700 |
commit | 1f3a43d9450189088ba8224b18d60b0efa8cbd81 (patch) | |
tree | 2f7a157dbc45641cbe2fb514f0ba7f3b388d6c6a | |
parent | d7a73f8c700edcf150d59a570e0173b60f84c7a7 (diff) | |
download | numpy-1f3a43d9450189088ba8224b18d60b0efa8cbd81.tar.gz |
MAINT: Use textwrap.dedent in f2py tests
Don't touch the fortran files, since indentation is signficant there and it makes things more error-prone
-rw-r--r-- | numpy/f2py/tests/test_callback.py | 6 | ||||
-rw-r--r-- | numpy/f2py/tests/test_mixed.py | 7 | ||||
-rw-r--r-- | numpy/f2py/tests/util.py | 72 |
3 files changed, 42 insertions, 43 deletions
diff --git a/numpy/f2py/tests/test_callback.py b/numpy/f2py/tests/test_callback.py index 824ef7b0c..21c29ba5f 100644 --- a/numpy/f2py/tests/test_callback.py +++ b/numpy/f2py/tests/test_callback.py @@ -68,7 +68,7 @@ cf2py intent(out) a @pytest.mark.slow def test_docstring(self): - expected = """ + expected = textwrap.dedent("""\ a = t(fun,[fun_extra_args]) Wrapper for ``t``. @@ -93,8 +93,8 @@ cf2py intent(out) a def fun(): return a Return objects: a : int - """ - assert_equal(self.module.t.__doc__, textwrap.dedent(expected).lstrip()) + """) + assert_equal(self.module.t.__doc__, expected) def check_function(self, name): t = getattr(self.module, name) diff --git a/numpy/f2py/tests/test_mixed.py b/numpy/f2py/tests/test_mixed.py index 28268ecc0..0337538ff 100644 --- a/numpy/f2py/tests/test_mixed.py +++ b/numpy/f2py/tests/test_mixed.py @@ -25,7 +25,7 @@ class TestMixed(util.F2PyTest): @pytest.mark.slow def test_docstring(self): - expected = """ + expected = textwrap.dedent("""\ a = bar11() Wrapper for ``bar11``. @@ -33,6 +33,5 @@ class TestMixed(util.F2PyTest): Returns ------- a : int - """ - assert_equal(self.module.bar11.__doc__, - textwrap.dedent(expected).lstrip()) + """) + assert_equal(self.module.bar11.__doc__, expected) diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py index 5fa5dadd2..d20dc5908 100644 --- a/numpy/f2py/tests/util.py +++ b/numpy/f2py/tests/util.py @@ -180,27 +180,27 @@ def _get_compiler_status(): # XXX: this is really ugly. But I don't know how to invoke Distutils # in a safer way... - code = """ -import os -import sys -sys.path = %(syspath)s - -def configuration(parent_name='',top_path=None): - global config - from numpy.distutils.misc_util import Configuration - config = Configuration('', parent_name, top_path) - return config - -from numpy.distutils.core import setup -setup(configuration=configuration) - -config_cmd = config.get_config_cmd() -have_c = config_cmd.try_compile('void foo() {}') -print('COMPILERS:%%d,%%d,%%d' %% (have_c, - config.have_f77c(), - config.have_f90c())) -sys.exit(99) -""" + code = textwrap.dedent("""\ + import os + import sys + sys.path = %(syspath)s + + def configuration(parent_name='',top_path=None): + global config + from numpy.distutils.misc_util import Configuration + config = Configuration('', parent_name, top_path) + return config + + from numpy.distutils.core import setup + setup(configuration=configuration) + + config_cmd = config.get_config_cmd() + have_c = config_cmd.try_compile('void foo() {}') + print('COMPILERS:%%d,%%d,%%d' %% (have_c, + config.have_f77c(), + config.have_f90c())) + sys.exit(99) + """) code = code % dict(syspath=repr(sys.path)) with temppath(suffix='.py') as script: @@ -259,21 +259,21 @@ def build_module_distutils(source_files, config_code, module_name, **kw): # Build script config_code = textwrap.dedent(config_code).replace("\n", "\n ") - code = """\ -import os -import sys -sys.path = %(syspath)s - -def configuration(parent_name='',top_path=None): - from numpy.distutils.misc_util import Configuration - config = Configuration('', parent_name, top_path) - %(config_code)s - return config - -if __name__ == "__main__": - from numpy.distutils.core import setup - setup(configuration=configuration) -""" % dict(config_code=config_code, syspath=repr(sys.path)) + code = textwrap.dedent("""\ + import os + import sys + sys.path = %(syspath)s + + def configuration(parent_name='',top_path=None): + from numpy.distutils.misc_util import Configuration + config = Configuration('', parent_name, top_path) + %(config_code)s + return config + + if __name__ == "__main__": + from numpy.distutils.core import setup + setup(configuration=configuration) + """) % dict(config_code=config_code, syspath=repr(sys.path)) script = os.path.join(d, get_temp_module_name() + '.py') dst_sources.append(script) |