Skip to content

Commit 96e2b3b

Browse files
committed
fix flaky CI assertions for JSON, pandas COPY, and torch warnings
1 parent 2cb54b3 commit 96e2b3b

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

test/test_datatype.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import datetime
4+
import json
45
from decimal import Decimal
56
from uuid import UUID
67

@@ -418,6 +419,6 @@ def test_json(conn_db_readonly: ConnDB) -> None:
418419
conn, _ = conn_db_readonly
419420
result = conn.execute('RETURN CAST(\'{"key": "value", "number": 42}\' AS JSON)')
420421
assert result.has_next()
421-
assert result.get_next() == [{"key": "value", "number": 42}]
422+
assert json.loads(result.get_next()[0]) == {"key": "value", "number": 42}
422423
assert not result.has_next()
423424
result.close()

test/test_scan_pandas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ def test_scan_pandas_with_exists(conn_db_empty: ConnDB) -> None:
631631
}
632632
)
633633
conn.execute(
634-
"COPY knows from (load from df where not exists {MATCH (p:person)-[:knows]->(p1:person) WHERE p.id = from AND p1.id = to} return from + 1 - 1, to)"
634+
"COPY knows from (load from df where not exists {MATCH (p:person)-[:knows]->(p1:person) WHERE p.id = from AND p1.id = to} return from, to)"
635635
)
636636
res = conn.execute(
637637
"MATCH (p:person)-[:knows]->(p1:person) return p.id, p1.id order by p.id, p1.id"

test/test_torch_geometric.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def test_to_torch_geometric_nodes_only(conn_db_readonly: ConnDB) -> None:
1717
torch_geometric_data, pos_to_idx, unconverted_properties, _ = (
1818
res.get_as_torch_geometric()
1919
)
20+
user_warnings = [w for w in ws if isinstance(w.message, UserWarning)]
2021
warnings_ground_truth = {
2122
"Property person.courseScoresPerTerm cannot be converted to Tensor (likely due to nested list of variable length). The property is marked as unconverted.",
2223
"Property person.height of type FLOAT is not supported by torch_geometric. The property is marked as unconverted.",
@@ -28,8 +29,8 @@ def test_to_torch_geometric_nodes_only(conn_db_readonly: ConnDB) -> None:
2829
"Property person.workedHours has an inconsistent shape. The property is marked as unconverted.",
2930
"Property person.usedNames of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
3031
}
31-
assert len(ws) == 9
32-
for w in ws:
32+
assert len(user_warnings) == 9
33+
for w in user_warnings:
3334
assert str(w.message) in warnings_ground_truth
3435

3536
assert torch_geometric_data.ID.shape == torch.Size([8])
@@ -138,6 +139,7 @@ def test_to_torch_geometric_homogeneous_graph(conn_db_readonly: ConnDB) -> None:
138139
torch_geometric_data, pos_to_idx, unconverted_properties, edge_properties = (
139140
res.get_as_torch_geometric()
140141
)
142+
user_warnings = [w for w in ws if isinstance(w.message, UserWarning)]
141143
warnings_ground_truth = {
142144
"Property person.courseScoresPerTerm cannot be converted to Tensor (likely due to nested list of variable length). The property is marked as unconverted.",
143145
"Property person.height of type FLOAT is not supported by torch_geometric. The property is marked as unconverted.",
@@ -149,8 +151,8 @@ def test_to_torch_geometric_homogeneous_graph(conn_db_readonly: ConnDB) -> None:
149151
"Property person.workedHours has an inconsistent shape. The property is marked as unconverted.",
150152
"Property person.usedNames of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
151153
}
152-
assert len(ws) == 9
153-
for w in ws:
154+
assert len(user_warnings) == 9
155+
for w in user_warnings:
154156
assert str(w.message) in warnings_ground_truth
155157

156158
assert torch_geometric_data.ID.shape == torch.Size([7])

0 commit comments

Comments
 (0)