mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Fix test suite failure without numpy and improve module init diagnostics
Fixes #357.
This commit is contained in:
@@ -202,3 +202,27 @@ def pytest_namespace():
|
||||
'requires_eigen_and_scipy': skipif(not have_eigen or not scipy,
|
||||
reason="eigen and/or scipy are not installed"),
|
||||
}
|
||||
|
||||
|
||||
def _test_import_pybind11():
|
||||
"""Early diagnostic for test module initialization errors
|
||||
|
||||
When there is an error during initialization, the first import will report the
|
||||
real error while all subsequent imports will report nonsense. This import test
|
||||
is done early (in the pytest configuration file, before any tests) in order to
|
||||
avoid the noise of having all tests fail with identical error messages.
|
||||
|
||||
Any possible exception is caught here and reported manually *without* the stack
|
||||
trace. This further reduces noise since the trace would only show pytest internals
|
||||
which are not useful for debugging pybind11 module issues.
|
||||
"""
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
import pybind11_tests
|
||||
except Exception as e:
|
||||
print("Failed to import pybind11_tests from pytest:")
|
||||
print(" {}: {}".format(type(e).__name__, e))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
_test_import_pybind11()
|
||||
|
||||
Reference in New Issue
Block a user