diff options
author | Hameer Abbasi <einstein.edison@gmail.com> | 2019-10-08 02:22:41 +0500 |
---|---|---|
committer | Hameer Abbasi <einstein.edison@gmail.com> | 2019-10-08 02:22:41 +0500 |
commit | 2246f68b1af3f27bce9cbee3a49aa10e1dd7cb80 (patch) | |
tree | 6eaa55f3167512cc044304512be5ac87f215d9ff /numpy/tests/test_public_api.py | |
parent | 750a59e9310ff1226ff2912fc29a815c2ce07ed2 (diff) | |
parent | d2c57616d369fdb5b4ea22b77d314785b1a0508e (diff) | |
download | numpy-2246f68b1af3f27bce9cbee3a49aa10e1dd7cb80.tar.gz |
Merge branch 'uarray' into uarray-me
Diffstat (limited to 'numpy/tests/test_public_api.py')
-rw-r--r-- | numpy/tests/test_public_api.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index 807c98652..df2fc4802 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -1,6 +1,7 @@ from __future__ import division, absolute_import, print_function import sys +import subprocess import numpy as np import pytest @@ -69,6 +70,28 @@ def test_numpy_namespace(): assert bad_results == whitelist +@pytest.mark.parametrize('name', ['testing', 'Tester']) +def test_import_lazy_import(name): + """Make sure we can actually the the modules we lazy load. + + While not exported as part of the public API, it was accessible. With the + use of __getattr__ and __dir__, this isn't always true It can happen that + an infinite recursion may happen. + + This is the only way I found that would force the failure to appear on the + badly implemented code. + + We also test for the presence of the lazily imported modules in dir + + """ + exe = (sys.executable, '-c', "import numpy; numpy." + name) + result = subprocess.check_output(exe) + assert not result + + # Make sure they are still in the __dir__ + assert name in dir(np) + + def test_numpy_linalg(): bad_results = check_dir(np.linalg) assert bad_results == {} |