summaryrefslogtreecommitdiff
path: root/numpy/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/tests')
-rw-r--r--numpy/tests/test_numpy_config.py44
-rw-r--r--numpy/tests/test_public_api.py13
2 files changed, 53 insertions, 4 deletions
diff --git a/numpy/tests/test_numpy_config.py b/numpy/tests/test_numpy_config.py
new file mode 100644
index 000000000..82c1ad70b
--- /dev/null
+++ b/numpy/tests/test_numpy_config.py
@@ -0,0 +1,44 @@
+"""
+Check the numpy config is valid.
+"""
+import numpy as np
+import pytest
+from unittest.mock import Mock, patch
+
+pytestmark = pytest.mark.skipif(
+ not hasattr(np.__config__, "_built_with_meson"),
+ reason="Requires Meson builds",
+)
+
+
+class TestNumPyConfigs:
+ REQUIRED_CONFIG_KEYS = [
+ "Compilers",
+ "Machine Information",
+ "Python Information",
+ ]
+
+ @patch("numpy.__config__._check_pyyaml")
+ def test_pyyaml_not_found(self, mock_yaml_importer):
+ mock_yaml_importer.side_effect = ModuleNotFoundError()
+ with pytest.warns(UserWarning):
+ np.show_config()
+
+ def test_dict_mode(self):
+ config = np.show_config(mode="dicts")
+
+ assert isinstance(config, dict)
+ assert all([key in config for key in self.REQUIRED_CONFIG_KEYS]), (
+ "Required key missing,"
+ " see index of `False` with `REQUIRED_CONFIG_KEYS`"
+ )
+
+ def test_invalid_mode(self):
+ with pytest.raises(AttributeError):
+ np.show_config(mode="foo")
+
+ def test_warn_to_add_tests(self):
+ assert len(np.__config__.DisplayModes) == 2, (
+ "New mode detected,"
+ " please add UT if applicable and increment this count"
+ )
diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py
index c41639043..eaa89aa6f 100644
--- a/numpy/tests/test_public_api.py
+++ b/numpy/tests/test_public_api.py
@@ -34,7 +34,6 @@ def test_numpy_namespace():
# None of these objects are publicly documented to be part of the main
# NumPy namespace (some are useful though, others need to be cleaned up)
undocumented = {
- 'Tester': 'numpy.testing._private.nosetester.NoseTester',
'_add_newdoc_ufunc': 'numpy.core._multiarray_umath._add_newdoc_ufunc',
'add_docstring': 'numpy.core._multiarray_umath.add_docstring',
'add_newdoc': 'numpy.core.function_base.add_newdoc',
@@ -64,7 +63,7 @@ def test_numpy_namespace():
@pytest.mark.skipif(IS_WASM, reason="can't start subprocess")
-@pytest.mark.parametrize('name', ['testing', 'Tester'])
+@pytest.mark.parametrize('name', ['testing'])
def test_import_lazy_import(name):
"""Make sure we can actually use the modules we lazy load.
@@ -137,6 +136,7 @@ PUBLIC_MODULES = ['numpy.' + s for s in [
"doc",
"doc.constants",
"doc.ufuncs",
+ "dtypes",
"exceptions",
"f2py",
"fft",
@@ -195,6 +195,7 @@ PRIVATE_BUT_PRESENT_MODULES = ['numpy.' + s for s in [
"core.umath",
"core.umath_tests",
"distutils.armccompiler",
+ "distutils.fujitsuccompiler",
"distutils.ccompiler",
'distutils.ccompiler_opt',
"distutils.command",
@@ -248,7 +249,6 @@ PRIVATE_BUT_PRESENT_MODULES = ['numpy.' + s for s in [
"distutils.numpy_distribution",
"distutils.pathccompiler",
"distutils.unixccompiler",
- "dual",
"f2py.auxfuncs",
"f2py.capi_maps",
"f2py.cb_rules",
@@ -289,7 +289,6 @@ PRIVATE_BUT_PRESENT_MODULES = ['numpy.' + s for s in [
"random.mtrand",
"random.bit_generator",
"testing.print_coercion_tables",
- "testing.utils",
]]
@@ -353,6 +352,8 @@ def test_all_modules_are_expected():
SKIP_LIST_2 = [
'numpy.math',
'numpy.distutils.log.sys',
+ 'numpy.distutils.log.logging',
+ 'numpy.distutils.log.warnings',
'numpy.doc.constants.re',
'numpy.doc.constants.textwrap',
'numpy.lib.emath',
@@ -471,6 +472,10 @@ def test_api_importable():
@pytest.mark.xfail(
+ hasattr(np.__config__, "_built_with_meson"),
+ reason = "Meson does not yet support entry points via pyproject.toml",
+)
+@pytest.mark.xfail(
sysconfig.get_config_var("Py_DEBUG") is not None,
reason=(
"NumPy possibly built with `USE_DEBUG=True ./tools/travis-test.sh`, "