summaryrefslogtreecommitdiff
path: root/networkx
diff options
context:
space:
mode:
authorRoss Barnowski <rossbar@berkeley.edu>2021-04-21 03:35:02 -0700
committerGitHub <noreply@github.com>2021-04-21 12:35:02 +0200
commit005e1f9c40056d0da94066953e51991a4d222487 (patch)
tree4e4dcc8c690d367fbce42723c2085c7f0ecddb61 /networkx
parent643f45705eb68068e430367847829a35152f0ca5 (diff)
downloadnetworkx-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')
-rw-r--r--networkx/algorithms/bipartite/tests/test_edgelist.py4
-rw-r--r--networkx/classes/tests/historical_tests.py6
-rw-r--r--networkx/readwrite/tests/test_adjlist.py20
-rw-r--r--networkx/readwrite/tests/test_edgelist.py8
4 files changed, 19 insertions, 19 deletions
diff --git a/networkx/algorithms/bipartite/tests/test_edgelist.py b/networkx/algorithms/bipartite/tests/test_edgelist.py
index 4df378a3..2a8dc73e 100644
--- a/networkx/algorithms/bipartite/tests/test_edgelist.py
+++ b/networkx/algorithms/bipartite/tests/test_edgelist.py
@@ -148,7 +148,7 @@ class TestEdgelist:
bipartite.write_edgelist(G, fname)
H = bipartite.read_edgelist(fname)
H2 = bipartite.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()))
@@ -173,7 +173,7 @@ class TestEdgelist:
bipartite.write_edgelist(G, fname)
H = bipartite.read_edgelist(fname, nodetype=int, create_using=nx.MultiGraph())
H2 = bipartite.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)
diff --git a/networkx/classes/tests/historical_tests.py b/networkx/classes/tests/historical_tests.py
index c19396ad..f41f94da 100644
--- a/networkx/classes/tests/historical_tests.py
+++ b/networkx/classes/tests/historical_tests.py
@@ -324,7 +324,7 @@ class HistoricalTests:
H = G.copy() # copy
assert H.adj == G.adj
assert H.name == G.name
- assert H != G
+ assert H is not G
def test_subgraph(self):
G = self.G()
@@ -341,7 +341,7 @@ class HistoricalTests:
)
DG = G.to_directed()
- assert DG != G # directed copy or copy
+ assert DG is not G # directed copy or copy
assert DG.is_directed()
assert DG.name == G.name
@@ -364,7 +364,7 @@ class HistoricalTests:
[("A", "B"), ("A", "C"), ("B", "D"), ("C", "B"), ("C", "D")]
)
UG = G.to_undirected() # to_undirected
- assert UG != G
+ assert UG is not G
assert not UG.is_directed()
assert G.is_directed()
assert UG.name == G.name
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)