diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-04-12 19:33:41 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-12 19:33:41 -0600 |
commit | dea1239b6dcaf072fc9b70e6af0c0a100cead69e (patch) | |
tree | 223cc3d75875f8067a1ed535e21ae5ac67c2c1de | |
parent | c73865c057d25c64cf434adfebc38b2e289bdf7c (diff) | |
parent | 1f3a43d9450189088ba8224b18d60b0efa8cbd81 (diff) | |
download | numpy-dea1239b6dcaf072fc9b70e6af0c0a100cead69e.tar.gz |
Merge pull request #11829 from eric-wieser/f2py-dedent
MAINT: Use textwrap.dedent in f2py tests
-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) |