diff options
author | Warren Weckesser <warren.weckesser@gmail.com> | 2018-03-10 12:42:11 -0500 |
---|---|---|
committer | Warren Weckesser <warren.weckesser@gmail.com> | 2018-03-10 18:28:47 -0500 |
commit | 16331cc1cf9b2cf3505d0c4742a854dc00923d9d (patch) | |
tree | edb04657705a50a2d1a720e2974517c3abc9d4b3 /numpy/distutils/tests | |
parent | c486d8d0d496f6b366dc827a3d41ed1e9d593ec8 (diff) | |
download | numpy-16331cc1cf9b2cf3505d0c4742a854dc00923d9d.tar.gz |
BUG: distutils: Remove named templates from the output.
The code now does not copy the named templates found outside
a function or subroutine to the output file.
Fixes gh-10712.
Diffstat (limited to 'numpy/distutils/tests')
-rw-r--r-- | numpy/distutils/tests/test_from_template.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/numpy/distutils/tests/test_from_template.py b/numpy/distutils/tests/test_from_template.py new file mode 100644 index 000000000..d3c513437 --- /dev/null +++ b/numpy/distutils/tests/test_from_template.py @@ -0,0 +1,48 @@ + +from numpy.distutils.from_template import process_str +from numpy.testing import assert_equal, run_module_suite + + +pyf_src = """ +python module foo + <_rd=real,double precision> + interface + subroutine <s,d>foosub(tol) + <_rd>, intent(in,out) :: tol + end subroutine <s,d>foosub + end interface +end python module foo +""" + +expected_pyf = """ +python module foo + interface + subroutine sfoosub(tol) + real, intent(in,out) :: tol + end subroutine sfoosub + subroutine dfoosub(tol) + double precision, intent(in,out) :: tol + end subroutine dfoosub + end interface +end python module foo +""" + + +def normalize_whitespace(s): + """ + Remove leading and trailing whitespace, and convert internal + stretches of whitespace to a single space. + """ + return ' '.join(s.split()) + + +def test_from_template(): + """Regression test for gh-10712.""" + pyf = process_str(pyf_src) + normalized_pyf = normalize_whitespace(pyf) + normalized_expected_pyf = normalize_whitespace(expected_pyf) + assert_equal(normalized_pyf, normalized_expected_pyf) + + +if __name__ == "__main__": + run_module_suite() |