Skip to content

Commit d5844a4

Browse files
committed
conftest.py: ignore ImportErrors for sage.libs.eclib if disabled
When sage.libs.eclib doesn't exist, pytest will still try to collect *.py files that import it, leading to an ImportError. We add eclib to the list of feature-backed modules with workarounds for this issue.
1 parent 7b46ff5 commit d5844a4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

conftest.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,13 @@ def _find(
130130
# tests), but that would require duplication
131131
# for as long as `sage -t` is still used.
132132
from sage.features.coxeter3 import Coxeter3
133-
from sage.features.sagemath import sage__libs__giac
133+
from sage.features.sagemath import (sage__libs__eclib,
134+
sage__libs__giac)
134135
from sage.features.standard import PythonModule
135136

136137
exc_list = ["valgrind"]
138+
if not sage__libs__eclib().is_present():
139+
exc_list.append("sage.libs.eclib")
137140
if not PythonModule("rpy2").is_present():
138141
exc_list.append("rpy2")
139142
if not Coxeter3().is_present():
@@ -142,8 +145,9 @@ def _find(
142145
exc_list.append("sagemath_giac")
143146

144147
# Ignore import errors, but only when the associated
145-
# feature is actually disabled.
146-
if exception.name in exc_list:
148+
# feature is actually disabled. Use startswith() so
149+
# that sage.libs.foo matches all of sage.libs.foo.*
150+
if any(exception.name.startswith(e) for e in exc_list):
147151
pytest.skip(
148152
f"unable to import module {self.path} due to missing feature {exception.name}"
149153
)

0 commit comments

Comments
 (0)