Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous test improvements #1219

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/digraph/test_is_semi_connected.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ def test_is_semi_connected_directed_star_graph(self):
self.assertEqual(rustworkx.is_semi_connected(graph), naive_semi_connected(graph))

def test_is_semi_connected_directed_grid_graph(self):
graph = rustworkx.generators.directed_grid_graph(50, 50)
graph = rustworkx.generators.directed_grid_graph(10, 10)
self.assertEqual(rustworkx.is_semi_connected(graph), naive_semi_connected(graph))
1 change: 0 additions & 1 deletion tests/graph/test_coloring.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ def preset(edge_idx):

with self.subTest():
edge_colors = rustworkx.graph_greedy_edge_color(graph, preset_color_fn=preset)
print(f"{edge_colors = }")
self.assertEqual({0: 1, 1: 2, 2: 0, 3: 0, 4: 2, 5: 1}, edge_colors)

with self.subTest(strategy=rustworkx.ColoringStrategy.Degree):
Expand Down
7 changes: 0 additions & 7 deletions tests/graph/test_max_weight_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ def get_nx_weight(edge):
for (u, v) in rx_matches:
if (u, v) not in nx_matches:
if (v, u) not in nx_matches:
print(
f"seed {seed} failed. Element {(u, v)} and it's "
f"reverse {(v, u)} not found in networkx output.\nrustworkx"
f" output: {rx_matches}\nnetworkx output: {nx_matches}"
f"\nedge list: {list(rx_graph.weighted_edge_list())}\n"
"falling back to checking for a valid solution"
)
not_match = True
break
if not_match:
Expand Down
33 changes: 17 additions & 16 deletions tests/visualization/test_graphviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,20 @@ def test_escape_sequences(self):
}

for escaped_seq, raw_seq in escape_sequences.items():

def node_attr(node):
"""
Define node attributes including escape sequences for labels and tooltips.
"""
label = f"label{escaped_seq}"
tooltip = f"tooltip{escaped_seq}"
return {"label": label, "tooltip": tooltip}

# Draw the graph using graphviz_draw
dot_str = graph.to_dot(node_attr)

# Assert that the escape sequences are correctly placed and escaped in the dot string
self.assertIn(
escaped_seq, dot_str, f"Escape sequence {escaped_seq} not found in dot output"
)
with self.subTest(chr=ord(raw_seq)):

def node_attr(node):
"""
Define node attributes including escape sequences for labels and tooltips.
"""
label = f"label{escaped_seq}"
tooltip = f"tooltip{escaped_seq}"
return {"label": label, "tooltip": tooltip}

# Draw the graph using graphviz_draw
dot_str = graph.to_dot(node_attr)

# Assert that the escape sequences are correctly placed and escaped in the dot string
self.assertIn(
escaped_seq, dot_str, f"Escape sequence {escaped_seq} not found in dot output"
)