diff options
author | Ross Barnowski <rossbar@berkeley.edu> | 2021-04-21 03:35:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-21 12:35:02 +0200 |
commit | 005e1f9c40056d0da94066953e51991a4d222487 (patch) | |
tree | 4e4dcc8c690d367fbce42723c2085c7f0ecddb61 /networkx/readwrite | |
parent | 643f45705eb68068e430367847829a35152f0ca5 (diff) | |
download | networkx-005e1f9c40056d0da94066953e51991a4d222487.tar.gz |
TST: be more explicit about instance comparison. (#4748)
Some tests relied on __eq__ or __ne__ to check whether or
not two Graph instances where the same instance. Use is
and is not instead.
Diffstat (limited to 'networkx/readwrite')
-rw-r--r-- | networkx/readwrite/tests/test_adjlist.py | 20 | ||||
-rw-r--r-- | networkx/readwrite/tests/test_edgelist.py | 8 |
2 files changed, 14 insertions, 14 deletions
diff --git a/networkx/readwrite/tests/test_adjlist.py b/networkx/readwrite/tests/test_adjlist.py index e2a655ef..0066111a 100644 --- a/networkx/readwrite/tests/test_adjlist.py +++ b/networkx/readwrite/tests/test_adjlist.py @@ -85,7 +85,7 @@ class TestAdjlist: nx.write_adjlist(G, fname) H = nx.read_adjlist(fname) H2 = nx.read_adjlist(fname) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) @@ -97,7 +97,7 @@ class TestAdjlist: nx.write_adjlist(G, fname) H = nx.read_adjlist(fname, create_using=nx.DiGraph()) H2 = nx.read_adjlist(fname, create_using=nx.DiGraph()) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) @@ -109,7 +109,7 @@ class TestAdjlist: nx.write_adjlist(G, fname) H = nx.read_adjlist(fname, nodetype=int) H2 = nx.read_adjlist(fname, nodetype=int) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) @@ -121,7 +121,7 @@ class TestAdjlist: nx.write_adjlist(G, fname) H = nx.read_adjlist(fname, nodetype=int, create_using=nx.MultiGraph()) H2 = nx.read_adjlist(fname, nodetype=int, create_using=nx.MultiGraph()) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) @@ -133,7 +133,7 @@ class TestAdjlist: nx.write_adjlist(G, fname) H = nx.read_adjlist(fname, nodetype=int, create_using=nx.MultiDiGraph()) H2 = nx.read_adjlist(fname, nodetype=int, create_using=nx.MultiDiGraph()) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) @@ -196,7 +196,7 @@ class TestMultilineAdjlist: nx.write_multiline_adjlist(G, fname) H = nx.read_multiline_adjlist(fname) H2 = nx.read_multiline_adjlist(fname) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) @@ -208,7 +208,7 @@ class TestMultilineAdjlist: nx.write_multiline_adjlist(G, fname) H = nx.read_multiline_adjlist(fname, create_using=nx.DiGraph()) H2 = nx.read_multiline_adjlist(fname, create_using=nx.DiGraph()) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) @@ -220,7 +220,7 @@ class TestMultilineAdjlist: nx.write_multiline_adjlist(G, fname) H = nx.read_multiline_adjlist(fname, nodetype=int) H2 = nx.read_multiline_adjlist(fname, nodetype=int) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) @@ -234,7 +234,7 @@ class TestMultilineAdjlist: H2 = nx.read_multiline_adjlist( fname, nodetype=int, create_using=nx.MultiGraph() ) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) @@ -250,7 +250,7 @@ class TestMultilineAdjlist: H2 = nx.read_multiline_adjlist( fname, nodetype=int, create_using=nx.MultiDiGraph() ) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) diff --git a/networkx/readwrite/tests/test_edgelist.py b/networkx/readwrite/tests/test_edgelist.py index f159f2b1..de3f0146 100644 --- a/networkx/readwrite/tests/test_edgelist.py +++ b/networkx/readwrite/tests/test_edgelist.py @@ -250,7 +250,7 @@ class TestEdgelist: nx.write_edgelist(G, fname) H = nx.read_edgelist(fname) H2 = nx.read_edgelist(fname) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs G.remove_node("g") # isolated nodes are not written in edgelist assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) @@ -263,7 +263,7 @@ class TestEdgelist: nx.write_edgelist(G, fname) H = nx.read_edgelist(fname, create_using=nx.DiGraph()) H2 = nx.read_edgelist(fname, create_using=nx.DiGraph()) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs G.remove_node("g") # isolated nodes are not written in edgelist assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) @@ -288,7 +288,7 @@ class TestEdgelist: nx.write_edgelist(G, fname) H = nx.read_edgelist(fname, nodetype=int, create_using=nx.MultiGraph()) H2 = nx.read_edgelist(fname, nodetype=int, create_using=nx.MultiGraph()) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) @@ -300,7 +300,7 @@ class TestEdgelist: nx.write_edgelist(G, fname) H = nx.read_edgelist(fname, nodetype=int, create_using=nx.MultiDiGraph()) H2 = nx.read_edgelist(fname, nodetype=int, create_using=nx.MultiDiGraph()) - assert H != H2 # they should be different graphs + assert H is not H2 # they should be different graphs assert_nodes_equal(list(H), list(G)) assert_edges_equal(list(H.edges()), list(G.edges())) os.close(fd) |