Skip to content

Commit bc97e50

Browse files
committed
fix(tests): improve exception handling for Windows-specific errors in import tests
1 parent 851ca72 commit bc97e50

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

bindings/python/tests/test_import_database.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ def _import_result_ok(result_set):
8080
return row
8181

8282

83+
def _exception_chain_text(exc: BaseException) -> str:
84+
parts = []
85+
current = exc
86+
seen = set()
87+
while current is not None and id(current) not in seen:
88+
seen.add(id(current))
89+
parts.append(str(current))
90+
current = current.__cause__ or current.__context__
91+
return "\n".join(parts).lower()
92+
93+
8394
def test_import_database_csv_documents(temp_db_path, sample_csv_path):
8495
with arcadedb.create_database(temp_db_path) as db:
8596
result = db.command("sql", f"IMPORT DATABASE {_file_url(sample_csv_path)}")
@@ -144,8 +155,15 @@ def test_import_database_xml_vertices(temp_db_path, sample_xml_path):
144155
),
145156
)
146157
except arcadedb.ArcadeDBError as e:
147-
message = str(e).lower()
148-
if os.name == "nt" and "arrayindexoutofboundsexception" in message:
158+
message = _exception_chain_text(e)
159+
if os.name == "nt" and (
160+
"arrayindexoutofboundsexception" in message
161+
or "index 1 out of bounds for length 1" in message
162+
or (
163+
"error on importing database" in message
164+
and "error on parsing source" in message
165+
)
166+
):
149167
pytest.skip(
150168
"XML importer path currently fails on Windows runtime "
151169
f"(engine-side): {e}"
@@ -220,10 +238,17 @@ def test_import_database_rdf_fixture(temp_db_path):
220238
try:
221239
result = db.command("sql", f"IMPORT DATABASE {_file_url(str(rdf_file))}")
222240
except arcadedb.ArcadeDBError as e:
223-
message = str(e).lower()
241+
message = _exception_chain_text(e)
224242
if "rdf" in message or "cannot determine the file type" in message:
225243
pytest.skip(f"RDF import not available in current runtime: {e}")
226-
if os.name == "nt" and "arrayindexoutofboundsexception" in message:
244+
if os.name == "nt" and (
245+
"arrayindexoutofboundsexception" in message
246+
or "index 1 out of bounds for length 1" in message
247+
or (
248+
"error on importing database" in message
249+
and "error on parsing source" in message
250+
)
251+
):
227252
pytest.skip(
228253
"RDF importer path currently fails on Windows runtime "
229254
f"(engine-side): {e}"

0 commit comments

Comments
 (0)