Skip to content

Commit 121c52e

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 11fedce commit 121c52e

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
@@ -129,10 +129,13 @@ def _find(
129129
# tests), but that would require duplication
130130
# for as long as `sage -t` is still used.
131131
from sage.features.coxeter3 import Coxeter3
132-
from sage.features.sagemath import sage__libs__giac
132+
from sage.features.sagemath import (sage__libs__eclib,
133+
sage__libs__giac)
133134
from sage.features.standard import PythonModule
134135

135136
exc_list = ["valgrind"]
137+
if not sage__libs__eclib().is_present():
138+
exc_list.append("sage.libs.eclib")
136139
if not PythonModule("rpy2").is_present():
137140
exc_list.append("rpy2")
138141
if not Coxeter3().is_present():
@@ -141,8 +144,9 @@ def _find(
141144
exc_list.append("sagemath_giac")
142145

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

0 commit comments

Comments
 (0)