Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

test: guard the NodeEmbedder-dependent tests on gensim (#1963)

Shubham Srivastava433e40d72b2d
diff --git a/tests/context/test_banking_context_graphs_e2e.py b/tests/context/test_banking_context_graphs_e2e.py
index 097a9beb..a346ca22 100644
--- a/tests/context/test_banking_context_graphs_e2e.py
+++ b/tests/context/test_banking_context_graphs_e2e.py
@@ -210,6 +210,10 @@ class TestBankingDecisionSystem:
def test_enhanced_components_integration(self, mock_vector_store, mock_knowledge_graph):
"""Test integration of enhanced components with KG algorithms."""
+ # Constructing NodeEmbedder requires gensim (the optional
+ # graph-embeddings extra); see tests/test_issue_1513_slim_core.py
+ # for the contract that it raises without it.
+ pytest.importorskip("gensim")
print("\n=== Testing Enhanced Components Integration ===")
# Test enhanced DecisionQuery
diff --git a/tests/context/test_context_explainability_regression.py b/tests/context/test_context_explainability_regression.py
index 777ecec5..6b462710 100644
--- a/tests/context/test_context_explainability_regression.py
+++ b/tests/context/test_context_explainability_regression.py
@@ -448,6 +448,10 @@ class TestKGConsumerCompatibility:
def test_node_embedder_build_adjacency_normalizes_enriched_dicts(self):
"""NodeEmbedder._build_adjacency strips enriched dicts to node IDs (no crash, no None)."""
+ # Constructing NodeEmbedder requires gensim (the optional
+ # graph-embeddings extra); see tests/test_issue_1513_slim_core.py
+ # for the contract that it raises without it.
+ pytest.importorskip("gensim")
from semantica.kg.node_embeddings import NodeEmbedder
g = self._graph_with_nodes([("A", "Person"), ("B", "Person"), ("C", "Person")])
diff --git a/tests/kg/test_enhanced_algorithms_e2e.py b/tests/kg/test_enhanced_algorithms_e2e.py
index db1746b0..d1e34cfd 100644
--- a/tests/kg/test_enhanced_algorithms_e2e.py
+++ b/tests/kg/test_enhanced_algorithms_e2e.py
@@ -123,6 +123,10 @@ class TestEnhancedAlgorithmsE2E:
def test_node_embeddings_end_to_end(self, social_network_graph):
"""Test node embeddings end-to-end."""
+ # Constructing NodeEmbedder requires gensim (the optional
+ # graph-embeddings extra); see tests/test_issue_1513_slim_core.py
+ # for the contract that it raises without it.
+ pytest.importorskip("gensim")
embedder = NodeEmbedder()
embedder.enable_provenance = True
@@ -470,6 +474,10 @@ class TestEnhancedAlgorithmsE2E:
def test_comprehensive_workflow(self, social_network_graph, citation_network_graph, sample_embeddings):
"""Test comprehensive workflow combining all algorithms."""
+ # Constructing NodeEmbedder requires gensim (the optional
+ # graph-embeddings extra); see tests/test_issue_1513_slim_core.py
+ # for the contract that it raises without it.
+ pytest.importorskip("gensim")
# Initialize all algorithms
embedder = NodeEmbedder()
embedder.enable_provenance = True
diff --git a/tests/kg/test_provenance_integration.py b/tests/kg/test_provenance_integration.py
index 7119e13e..011a98d0 100644
--- a/tests/kg/test_provenance_integration.py
+++ b/tests/kg/test_provenance_integration.py
@@ -223,6 +223,10 @@ class TestProvenanceIntegration:
def test_node_embeddings_with_provenance(self, sample_graph_data):
"""Test node embeddings with provenance tracking."""
+ # Constructing NodeEmbedder requires gensim (the optional
+ # graph-embeddings extra); see tests/test_issue_1513_slim_core.py
+ # for the contract that it raises without it.
+ pytest.importorskip("gensim")
embedder = NodeEmbedder()
embedder.enable_provenance = True
@@ -366,6 +370,10 @@ class TestProvenanceIntegration:
def test_end_to_end_workflow(self, sample_graph_data, networkx_graph, sample_embeddings):
"""Test complete end-to-end workflow with provenance tracking."""
+ # Constructing NodeEmbedder requires gensim (the optional
+ # graph-embeddings extra); see tests/test_issue_1513_slim_core.py
+ # for the contract that it raises without it.
+ pytest.importorskip("gensim")
# Initialize all components with provenance
builder = GraphBuilderWithProvenance(provenance=True)
tracker = AlgorithmTrackerWithProvenance(provenance=True)
diff --git a/tests/test_030_realworld_comprehensive.py b/tests/test_030_realworld_comprehensive.py
index 739c1d71..05a97f18 100644
--- a/tests/test_030_realworld_comprehensive.py
+++ b/tests/test_030_realworld_comprehensive.py
@@ -822,6 +822,10 @@ class TestKGAlgorithmsRealWorld:
assert score > 0.95 # Very similar vectors
def test_node_embedder_generates_embeddings(self):
+ # Constructing NodeEmbedder requires gensim (the optional
+ # graph-embeddings extra); see tests/test_issue_1513_slim_core.py
+ # for the contract that it raises without it.
+ pytest.importorskip("gensim")
G = _build_nx_tech_graph()
embedder = NodeEmbedder(embedding_dimension=16, walk_length=10, num_walks=2, epochs=1)
node_labels = list({data.get("type", "entity") for _, data in G.nodes(data=True)})
diff --git a/tests/vector_store/test_decision_embedding_pipeline.py b/tests/vector_store/test_decision_embedding_pipeline.py
index 4b93d594..a4e0fc57 100644
--- a/tests/vector_store/test_decision_embedding_pipeline.py
+++ b/tests/vector_store/test_decision_embedding_pipeline.py
@@ -174,6 +174,10 @@ class TestDecisionEmbeddingPipeline:
def test_generate_structural_embedding_no_entities(self):
"""Test structural embedding without entities."""
+ # Constructing NodeEmbedder requires gensim (the optional
+ # graph-embeddings extra); see tests/test_issue_1513_slim_core.py
+ # for the contract that it raises without it.
+ pytest.importorskip("gensim")
decision_no_entities = {
"scenario": "Test decision",
"category": "test"