diff options
author | mattip <matti.picus@gmail.com> | 2020-05-06 02:14:05 +0300 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2020-05-06 02:14:05 +0300 |
commit | bdbcb856867a2e01482cfd0029b9e7f468b84f58 (patch) | |
tree | a03ef70ac26e6e61ebaa53349a4de6030504dcf6 /numpy/random/tests/test_extending.py | |
parent | fc6cd3846fde770e50d93ed7909f73728ee1e342 (diff) | |
download | numpy-bdbcb856867a2e01482cfd0029b9e7f468b84f58.tar.gz |
TST: add tag to __init__.pxd and test that the tag is found
Diffstat (limited to 'numpy/random/tests/test_extending.py')
-rw-r--r-- | numpy/random/tests/test_extending.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/numpy/random/tests/test_extending.py b/numpy/random/tests/test_extending.py index f7efafba9..77353463e 100644 --- a/numpy/random/tests/test_extending.py +++ b/numpy/random/tests/test_extending.py @@ -46,14 +46,24 @@ def test_cython(tmp_path): srcdir = os.path.join(os.path.dirname(__file__), '..') shutil.copytree(srcdir, tmp_path / 'random') # build the examples and "install" them into a temporary directory - env = os.environ.copy() + build_dir = tmp_path / 'random' / '_examples' / 'cython' subprocess.check_call([sys.executable, 'setup.py', 'build', 'install', '--prefix', str(tmp_path / 'installdir'), '--single-version-externally-managed', '--record', str(tmp_path/ 'tmp_install_log.txt'), ], - cwd=str(tmp_path / 'random' / '_examples' / 'cython'), - env=env) + cwd=str(build_dir), + ) + # gh-16162: make sure numpy's __init__.pxd was used for cython + # not really part of this test, but it is a convenient place to check + with open(build_dir / 'extending.c') as fid: + txt_to_find = 'NumPy API declarations from "numpy/__init__.pxd"' + for i, line in enumerate(fid): + if txt_to_find in line: + break + else: + assert False, ("Could not find '{}' in C file, " + "wrong pxd used".format(txt_to_find)) # get the path to the so's so1 = so2 = None with open(tmp_path /'tmp_install_log.txt') as fid: |