From 09b30ba69dd2e81a2728fd1259ca7b4d88470827 Mon Sep 17 00:00:00 2001 From: Jarrod Millman Date: Wed, 26 May 2021 08:59:54 -0700 Subject: Refactor testing utilities (#4829) * Refactor testing utilities Change `assert_edges_equal`, `assert_graphs_equal`, and `assert_nodes_equal` to be more pytest-idiomatic. For example, `assert_edges_equal` becomes the Boolean function `edges_equal` and then the assert is done the testing file (i.e., `assert edges_equal(edges1, edges2)`). This also makes these utility functions useful in nontesting situations where you want to compare edges, but not raise an exception based on the result. * Move testing utility functions * Use new testing utilities * Deprecate assert_*_equal testing utilities * Document node, edge, and graph equality helper functions * text nits. * Update networkx/tests/test_convert_pandas.py Co-authored-by: Ross Barnowski * Update networkx/readwrite/tests/test_sparse6.py Co-authored-by: Ross Barnowski * Update networkx/readwrite/tests/test_graph6.py Co-authored-by: Ross Barnowski * Update networkx/generators/tests/test_classic.py Co-authored-by: Ross Barnowski * Update networkx/algorithms/tree/tests/test_operations.py Co-authored-by: Ross Barnowski * Update networkx/algorithms/tree/tests/test_coding.py Co-authored-by: Ross Barnowski * Update networkx/algorithms/tests/test_dag.py Co-authored-by: Ross Barnowski * Update networkx/algorithms/minors/tests/test_contraction.py Co-authored-by: Ross Barnowski * add short equality description to docstring * Suppress known warnings Co-authored-by: Ross Barnowski Co-authored-by: Dan Schult --- networkx/drawing/tests/test_agraph.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'networkx/drawing/tests/test_agraph.py') diff --git a/networkx/drawing/tests/test_agraph.py b/networkx/drawing/tests/test_agraph.py index bf91f335..33e77c36 100644 --- a/networkx/drawing/tests/test_agraph.py +++ b/networkx/drawing/tests/test_agraph.py @@ -6,7 +6,7 @@ import pytest pygraphviz = pytest.importorskip("pygraphviz") -from networkx.testing import assert_edges_equal, assert_nodes_equal, assert_graphs_equal +from networkx.utils import nodes_equal, edges_equal, graphs_equal import networkx as nx @@ -20,8 +20,8 @@ class TestAGraph: return G def assert_equal(self, G1, G2): - assert_nodes_equal(G1.nodes(), G2.nodes()) - assert_edges_equal(G1.edges(), G2.edges()) + assert nodes_equal(G1.nodes(), G2.nodes()) + assert edges_equal(G1.edges(), G2.edges()) assert G1.graph["metal"] == G2.graph["metal"] def agraph_checks(self, G): @@ -188,21 +188,21 @@ class TestAGraph: G = nx.Graph() A = nx.nx_agraph.to_agraph(G) H = nx.nx_agraph.from_agraph(A) - # assert_graphs_equal(G, H) + # assert graphs_equal(G, H) AA = nx.nx_agraph.to_agraph(H) HH = nx.nx_agraph.from_agraph(AA) - assert_graphs_equal(H, HH) + assert graphs_equal(H, HH) G.graph["graph"] = {} G.graph["node"] = {} G.graph["edge"] = {} - assert_graphs_equal(G, HH) + assert graphs_equal(G, HH) @pytest.mark.xfail(reason="integer->string node conversion in round trip") def test_round_trip_integer_nodes(self): G = nx.complete_graph(3) A = nx.nx_agraph.to_agraph(G) H = nx.nx_agraph.from_agraph(A) - assert_graphs_equal(G, H) + assert graphs_equal(G, H) def test_graphviz_alias(self): G = self.build_graph(nx.Graph()) -- cgit v1.2.1