diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2022-02-16 23:00:29 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2022-02-16 23:00:29 +0100 |
commit | 808fd6844132603765ad9568af0250bd6e148a95 (patch) | |
tree | b7d3310c32fa64ca249b6ac1fd914312702bdcfa /tests/build | |
parent | 6e56db7e7d75d05a699460419ccc0a978956a4b5 (diff) | |
parent | 6e2c8d0cddfc626e74728ece87b3974c4ffd5536 (diff) | |
download | cython-808fd6844132603765ad9568af0250bd6e148a95.tar.gz |
Merge branch '0.29.x'
Diffstat (limited to 'tests/build')
-rw-r--r-- | tests/build/depfile.srctree | 6 | ||||
-rw-r--r-- | tests/build/depfile_numpy.srctree | 24 | ||||
-rw-r--r-- | tests/build/depfile_package.srctree | 13 |
3 files changed, 25 insertions, 18 deletions
diff --git a/tests/build/depfile.srctree b/tests/build/depfile.srctree index 053ec1e7d..0b8019df9 100644 --- a/tests/build/depfile.srctree +++ b/tests/build/depfile.srctree @@ -1,5 +1,7 @@ +""" CYTHONIZE -M foo.pyx PYTHON check.py +""" ######## foo.pyx ######## @@ -25,9 +27,7 @@ cdef inline void empty(): ######## check.py ######## -import os - with open("foo.c.dep", "r") as f: - contents = f.read().replace("\n", " ").replace("\\", "") + contents = f.read().replace("\\\n", " ").replace("\n", " ") assert sorted(contents.split()) == ['bar.pxd', 'baz.pxi', 'foo.c:', 'foo.pyx'], contents diff --git a/tests/build/depfile_numpy.srctree b/tests/build/depfile_numpy.srctree index 5c3a62119..27f3bb283 100644 --- a/tests/build/depfile_numpy.srctree +++ b/tests/build/depfile_numpy.srctree @@ -1,7 +1,9 @@ # tag: numpy +""" CYTHONIZE -M dep_np.pyx PYTHON check_np.py +""" ######## dep_np.pyx ######## @@ -12,14 +14,14 @@ np.import_array() ######## check_np.py ######## -import os +import os.path import re import numpy as np import Cython with open("dep_np.c.dep", "r") as f: - contents = f.read().replace("\n", " ").replace("\\", "") + contents = f.read().replace('\\\n', ' ').replace('\n', ' ') contents = contents.split() @@ -32,19 +34,25 @@ contents = [fname.replace(np_prefix, "np_prefix") for fname in contents] # filter out the version number from `np_prefix/__init__.cython-30.pxd`. contents = [re.sub('[.]cython-[0-9]+', '', entry) for entry in contents] -expected = ['cy_prefix/Includes/cpython/object.pxd', +contents = [path.split(os.sep) for path in contents] +contents.sort() + +expected = [path.split('/') for path in [ + 'cy_prefix/Includes/cpython/object.pxd', 'cy_prefix/Includes/cpython/ref.pxd', 'cy_prefix/Includes/cpython/type.pxd', 'cy_prefix/Includes/libc/stdio.pxd', 'cy_prefix/Includes/libc/string.pxd', 'dep_np.c:', - 'dep_np.pyx',] + 'dep_np.pyx', +]] # Also account for legacy numpy versions, which do not ship # `__init__.pxd` hence the fallback is used: -if 'cy_prefix/Includes/numpy/__init__.pxd' in contents: - expected.append('cy_prefix/Includes/numpy/__init__.pxd') +if ['cy_prefix', 'Includes', 'numpy', '__init__.pxd'] in contents: + expected.append(['cy_prefix', 'Includes', 'numpy', '__init__.pxd']) else: - expected.append('np_prefix/__init__.pxd') + expected.append(['np_prefix', '__init__.pxd']) -assert sorted(contents) == sorted(expected), sorted(contents) +expected.sort() +assert contents == expected, contents diff --git a/tests/build/depfile_package.srctree b/tests/build/depfile_package.srctree index b4d98f18f..d711528d6 100644 --- a/tests/build/depfile_package.srctree +++ b/tests/build/depfile_package.srctree @@ -1,16 +1,16 @@ -''' +""" PYTHON -m Cython.Build.Cythonize -i pkg --depfile PYTHON package_test.py -''' +""" ######## package_test.py ######## -import os +import os.path with open("pkg/test.c.dep", "r") as f: - contents = f.read().replace("\n", " ").replace("\\", "") + contents = f.read().replace("\\\n", " ").replace("\\\n", " ") -assert sorted(contents.split()) == sorted(['test.c:', 'sub/incl.pxi', 'test.pxd', 'test.pyx']), contents +assert sorted(contents.split()) == sorted(['test.c:', os.path.join('sub', 'incl.pxi'), 'test.pxd', 'test.pyx']), contents with open("pkg/sub/test.c.dep", "r") as f: @@ -18,7 +18,7 @@ with open("pkg/sub/test.c.dep", "r") as f: contents = [os.path.relpath(entry, '.') if os.path.isabs(entry) else entry for entry in contents.split()] -assert sorted(contents) == sorted(['test.c:', 'incl.pxi', 'test.pyx', 'pkg/test.pxd']), contents # last is really one level up +assert sorted(contents) == sorted(['test.c:', 'incl.pxi', 'test.pyx', os.path.join('pkg', 'test.pxd')]), contents # last is really one level up ######## pkg/__init__.py ######## @@ -55,4 +55,3 @@ TEST = 'pkg.sub.test' ######## pkg/sub/incl.pxi ######## pass - |