diff options
| author | Jarrod Millman <jarrod.millman@gmail.com> | 2019-10-08 22:18:40 -0700 |
|---|---|---|
| committer | Jarrod Millman <jarrod.millman@gmail.com> | 2019-10-12 09:21:57 -0700 |
| commit | 75e0c43bef21f764c669244fb57f658b4afc94e9 (patch) | |
| tree | 7ecc0f885d8b80e60508a8b4960dd28e53c189f4 /networkx/readwrite/json_graph/tests | |
| parent | 4093b6b22d681b701bd4dc5a201e7944cd50e268 (diff) | |
| download | networkx-75e0c43bef21f764c669244fb57f658b4afc94e9.tar.gz | |
Convert nose.tools.assert_* functions into asserts
Diffstat (limited to 'networkx/readwrite/json_graph/tests')
5 files changed, 56 insertions, 56 deletions
diff --git a/networkx/readwrite/json_graph/tests/test_adjacency.py b/networkx/readwrite/json_graph/tests/test_adjacency.py index 5dbb84ce..7019d875 100644 --- a/networkx/readwrite/json_graph/tests/test_adjacency.py +++ b/networkx/readwrite/json_graph/tests/test_adjacency.py @@ -19,30 +19,30 @@ class TestAdjacency: G.graph[1] = 'one' H = adjacency_graph(adjacency_data(G)) - assert_equal(H.graph['foo'], 'bar') - assert_equal(H.nodes[1]['color'], 'red') - assert_equal(H[1][2]['width'], 7) + assert H.graph['foo'] == 'bar' + assert H.nodes[1]['color'] == 'red' + assert H[1][2]['width'] == 7 d = json.dumps(adjacency_data(G)) H = adjacency_graph(json.loads(d)) - assert_equal(H.graph['foo'], 'bar') - assert_equal(H.graph[1], 'one') - assert_equal(H.nodes[1]['color'], 'red') - assert_equal(H[1][2]['width'], 7) + assert H.graph['foo'] == 'bar' + assert H.graph[1] == 'one' + assert H.nodes[1]['color'] == 'red' + assert H[1][2]['width'] == 7 def test_digraph(self): G = nx.DiGraph() nx.add_path(G, [1, 2, 3]) H = adjacency_graph(adjacency_data(G)) - assert_true(H.is_directed()) + assert H.is_directed() nx.is_isomorphic(G, H) def test_multidigraph(self): G = nx.MultiDiGraph() nx.add_path(G, [1, 2, 3]) H = adjacency_graph(adjacency_data(G)) - assert_true(H.is_directed()) - assert_true(H.is_multigraph()) + assert H.is_directed() + assert H.is_multigraph() def test_multigraph(self): G = nx.MultiGraph() @@ -50,7 +50,7 @@ class TestAdjacency: G.add_edge(1, 2, key='second', color='blue') H = adjacency_graph(adjacency_data(G)) nx.is_isomorphic(G, H) - assert_equal(H[1][2]['second']['color'], 'blue') + assert H[1][2]['second']['color'] == 'blue' @raises(nx.NetworkXError) def test_exception(self): diff --git a/networkx/readwrite/json_graph/tests/test_cytoscape.py b/networkx/readwrite/json_graph/tests/test_cytoscape.py index 502d3af1..4dc7b560 100644 --- a/networkx/readwrite/json_graph/tests/test_cytoscape.py +++ b/networkx/readwrite/json_graph/tests/test_cytoscape.py @@ -20,42 +20,42 @@ class TestCytoscape: G.add_node(3, name="node", id="123") H = cytoscape_graph(cytoscape_data(G)) - assert_equal(H.graph['foo'], 'bar') - assert_equal(H.nodes[1]['color'], 'red') - assert_equal(H[1][2]['width'], 7) - assert_equal(H.nodes[3]['name'], 'node') - assert_equal(H.nodes[3]['id'], '123') + assert H.graph['foo'] == 'bar' + assert H.nodes[1]['color'] == 'red' + assert H[1][2]['width'] == 7 + assert H.nodes[3]['name'] == 'node' + assert H.nodes[3]['id'] == '123' d = json.dumps(cytoscape_data(G)) H = cytoscape_graph(json.loads(d)) - assert_equal(H.graph['foo'], 'bar') - assert_equal(H.graph[1], 'one') - assert_equal(H.nodes[1]['color'], 'red') - assert_equal(H[1][2]['width'], 7) - assert_equal(H.nodes[3]['name'], 'node') - assert_equal(H.nodes[3]['id'], '123') + assert H.graph['foo'] == 'bar' + assert H.graph[1] == 'one' + assert H.nodes[1]['color'] == 'red' + assert H[1][2]['width'] == 7 + assert H.nodes[3]['name'] == 'node' + assert H.nodes[3]['id'] == '123' def test_digraph(self): G = nx.DiGraph() nx.add_path(G, [1, 2, 3]) H = cytoscape_graph(cytoscape_data(G)) - assert_true(H.is_directed()) + assert H.is_directed() nx.is_isomorphic(G, H) def test_multidigraph(self): G = nx.MultiDiGraph() nx.add_path(G, [1, 2, 3]) H = cytoscape_graph(cytoscape_data(G)) - assert_true(H.is_directed()) - assert_true(H.is_multigraph()) + assert H.is_directed() + assert H.is_multigraph() def test_multigraph(self): G = nx.MultiGraph() G.add_edge(1, 2, key='first') G.add_edge(1, 2, key='second', color='blue') H = cytoscape_graph(cytoscape_data(G)) - assert_true(nx.is_isomorphic(G, H)) - assert_equal(H[1][2]['second']['color'], 'blue') + assert nx.is_isomorphic(G, H) + assert H[1][2]['second']['color'] == 'blue' @raises(nx.NetworkXError) def test_exception(self): diff --git a/networkx/readwrite/json_graph/tests/test_jit.py b/networkx/readwrite/json_graph/tests/test_jit.py index c9e2c5d3..3725cbad 100644 --- a/networkx/readwrite/json_graph/tests/test_jit.py +++ b/networkx/readwrite/json_graph/tests/test_jit.py @@ -15,7 +15,7 @@ class TestJIT(object): G.add_edge('Node1', 'Node2') d = jit_data(G) K = jit_graph(json.loads(d)) - assert_true(nx.is_isomorphic(G, K)) + assert nx.is_isomorphic(G, K) def test_jit_2(self): G = nx.Graph() @@ -26,7 +26,7 @@ class TestJIT(object): G.add_edge(1, 2) d = jit_data(G) K = jit_graph(json.loads(d)) - assert_true(nx.is_isomorphic(G, K)) + assert nx.is_isomorphic(G, K) def test_jit_directed(self): G = nx.DiGraph() @@ -37,7 +37,7 @@ class TestJIT(object): G.add_edge(1, 2) d = jit_data(G) K = jit_graph(json.loads(d), create_using=nx.DiGraph()) - assert_true(nx.is_isomorphic(G, K)) + assert nx.is_isomorphic(G, K) def test_jit_multi_directed(self): G = nx.MultiDiGraph() @@ -51,14 +51,14 @@ class TestJIT(object): H = nx.DiGraph(G) d = jit_data(H) K = jit_graph(json.loads(d), create_using=nx.MultiDiGraph()) - assert_true(nx.is_isomorphic(H, K)) + assert nx.is_isomorphic(H, K) K.add_edge(1, 2) - assert_false(nx.is_isomorphic(H, K)) - assert_true(nx.is_isomorphic(G, K)) + assert not nx.is_isomorphic(H, K) + assert nx.is_isomorphic(G, K) def test_jit_round_trip(self): G = nx.Graph() d = nx.jit_data(G) H = jit_graph(json.loads(d)) K = jit_graph(d) - assert_true(nx.is_isomorphic(H, K)) + assert nx.is_isomorphic(H, K) diff --git a/networkx/readwrite/json_graph/tests/test_node_link.py b/networkx/readwrite/json_graph/tests/test_node_link.py index 92a565b3..df323dee 100644 --- a/networkx/readwrite/json_graph/tests/test_node_link.py +++ b/networkx/readwrite/json_graph/tests/test_node_link.py @@ -10,7 +10,7 @@ class TestNodeLink: def test_graph(self): G = nx.path_graph(4) H = node_link_graph(node_link_data(G)) - assert_true(nx.is_isomorphic(G, H)) + assert nx.is_isomorphic(G, H) def test_graph_attributes(self): G = nx.path_graph(4) @@ -20,21 +20,21 @@ class TestNodeLink: G.graph['foo'] = 'bar' H = node_link_graph(node_link_data(G)) - assert_equal(H.graph['foo'], 'bar') - assert_equal(H.nodes[1]['color'], 'red') - assert_equal(H[1][2]['width'], 7) + assert H.graph['foo'] == 'bar' + assert H.nodes[1]['color'] == 'red' + assert H[1][2]['width'] == 7 d = json.dumps(node_link_data(G)) H = node_link_graph(json.loads(d)) - assert_equal(H.graph['foo'], 'bar') - assert_equal(H.graph['1'], 'one') - assert_equal(H.nodes[1]['color'], 'red') - assert_equal(H[1][2]['width'], 7) + assert H.graph['foo'] == 'bar' + assert H.graph['1'] == 'one' + assert H.nodes[1]['color'] == 'red' + assert H[1][2]['width'] == 7 def test_digraph(self): G = nx.DiGraph() H = node_link_graph(node_link_data(G)) - assert_true(H.is_directed()) + assert H.is_directed() def test_multigraph(self): G = nx.MultiGraph() @@ -42,7 +42,7 @@ class TestNodeLink: G.add_edge(1, 2, key='second', color='blue') H = node_link_graph(node_link_data(G)) nx.is_isomorphic(G, H) - assert_equal(H[1][2]['second']['color'], 'blue') + assert H[1][2]['second']['color'] == 'blue' def test_graph_with_tuple_nodes(self): G = nx.Graph() @@ -51,8 +51,8 @@ class TestNodeLink: dumped_d = json.dumps(d) dd = json.loads(dumped_d) H = node_link_graph(dd) - assert_equal(H.nodes[(0, 0)], G.nodes[(0, 0)]) - assert_equal(H[(0, 0)][(1, 0)]['color'], [255, 255, 0]) + assert H.nodes[(0, 0)] == G.nodes[(0, 0)] + assert H[(0, 0)][(1, 0)]['color'] == [255, 255, 0] def test_unicode_keys(self): try: @@ -65,7 +65,7 @@ class TestNodeLink: output = json.dumps(s, ensure_ascii=False) data = json.loads(output) H = node_link_graph(data) - assert_equal(H.nodes[1][q], q) + assert H.nodes[1][q] == q @raises(nx.NetworkXError) def test_exception(self): @@ -84,10 +84,10 @@ class TestNodeLink: G.add_node(q) G.add_edge('A', q) data = node_link_data(G) - assert_equal(data['links'][0]['source'], 'A') - assert_equal(data['links'][0]['target'], q) + assert data['links'][0]['source'] == 'A' + assert data['links'][0]['target'] == q H = node_link_graph(data) - assert_true(nx.is_isomorphic(G, H)) + assert nx.is_isomorphic(G, H) def test_custom_attrs(self): G = nx.path_graph(4) @@ -99,7 +99,7 @@ class TestNodeLink: attrs = dict(source='c_source', target='c_target', name='c_id', key='c_key', link='c_links') H = node_link_graph(node_link_data(G, attrs=attrs), multigraph=False, attrs=attrs) - assert_true(nx.is_isomorphic(G, H)) - assert_equal(H.graph['foo'], 'bar') - assert_equal(H.nodes[1]['color'], 'red') - assert_equal(H[1][2]['width'], 7) + assert nx.is_isomorphic(G, H) + assert H.graph['foo'] == 'bar' + assert H.nodes[1]['color'] == 'red' + assert H[1][2]['width'] == 7 diff --git a/networkx/readwrite/json_graph/tests/test_tree.py b/networkx/readwrite/json_graph/tests/test_tree.py index cb59532e..15a1fbb2 100644 --- a/networkx/readwrite/json_graph/tests/test_tree.py +++ b/networkx/readwrite/json_graph/tests/test_tree.py @@ -22,11 +22,11 @@ class TestTree: G.add_edge(1, 3, foo=10) G.add_edge(3, 4, foo=10) H = tree_graph(tree_data(G, 1)) - assert_equal(H.nodes[1]['color'], 'red') + assert H.nodes[1]['color'] == 'red' d = json.dumps(tree_data(G, 1)) H = tree_graph(json.loads(d)) - assert_equal(H.nodes[1]['color'], 'red') + assert H.nodes[1]['color'] == 'red' @raises(nx.NetworkXError) def test_exception(self): |
