diff options
author | Jarrod Millman <jarrod.millman@gmail.com> | 2019-10-11 01:43:23 -0700 |
---|---|---|
committer | Jarrod Millman <jarrod.millman@gmail.com> | 2019-10-12 09:26:31 -0700 |
commit | 9030951faa7b69f3845fb64663462688ffc8d923 (patch) | |
tree | fbd068cfb98d18050ad863cba6da4f5d58de3a81 /networkx/algorithms/connectivity | |
parent | 0a769465a0f1cf7ca40cd73560d4894c3a72f5c1 (diff) | |
download | networkx-9030951faa7b69f3845fb64663462688ffc8d923.tar.gz |
Replace nose.raises with pytest.raises context manager
Diffstat (limited to 'networkx/algorithms/connectivity')
-rw-r--r-- | networkx/algorithms/connectivity/tests/test_disjoint_paths.py | 92 | ||||
-rw-r--r-- | networkx/algorithms/connectivity/tests/test_kcomponents.py | 8 |
2 files changed, 50 insertions, 50 deletions
diff --git a/networkx/algorithms/connectivity/tests/test_disjoint_paths.py b/networkx/algorithms/connectivity/tests/test_disjoint_paths.py index 9bb1db6f..deebfe6f 100644 --- a/networkx/algorithms/connectivity/tests/test_disjoint_paths.py +++ b/networkx/algorithms/connectivity/tests/test_disjoint_paths.py @@ -6,7 +6,7 @@ # # NetworkX is distributed under a BSD license; see LICENSE.txt for more # information. -from nose.tools import raises +import pytest import networkx as nx from networkx.algorithms import flow @@ -159,79 +159,79 @@ def test_cutoff_disjoint_paths(): assert cutoff == len(node_dpaths), msg.format(flow_func.__name__) -@raises(nx.NetworkXError) def test_missing_source_edge_paths(): - G = nx.path_graph(4) - list(nx.edge_disjoint_paths(G, 10, 1)) + with pytest.raises(nx.NetworkXError): + G = nx.path_graph(4) + list(nx.edge_disjoint_paths(G, 10, 1)) -@raises(nx.NetworkXError) def test_missing_source_node_paths(): - G = nx.path_graph(4) - list(nx.node_disjoint_paths(G, 10, 1)) + with pytest.raises(nx.NetworkXError): + G = nx.path_graph(4) + list(nx.node_disjoint_paths(G, 10, 1)) -@raises(nx.NetworkXError) def test_missing_target_edge_paths(): - G = nx.path_graph(4) - list(nx.edge_disjoint_paths(G, 1, 10)) + with pytest.raises(nx.NetworkXError): + G = nx.path_graph(4) + list(nx.edge_disjoint_paths(G, 1, 10)) -@raises(nx.NetworkXError) def test_missing_target_node_paths(): - G = nx.path_graph(4) - list(nx.node_disjoint_paths(G, 1, 10)) + with pytest.raises(nx.NetworkXError): + G = nx.path_graph(4) + list(nx.node_disjoint_paths(G, 1, 10)) -@raises(nx.NetworkXNoPath) def test_not_weakly_connected_edges(): - G = nx.DiGraph() - nx.add_path(G, [1, 2, 3]) - nx.add_path(G, [4, 5]) - list(nx.edge_disjoint_paths(G, 1, 5)) + with pytest.raises(nx.NetworkXNoPath): + G = nx.DiGraph() + nx.add_path(G, [1, 2, 3]) + nx.add_path(G, [4, 5]) + list(nx.edge_disjoint_paths(G, 1, 5)) -@raises(nx.NetworkXNoPath) def test_not_weakly_connected_nodes(): - G = nx.DiGraph() - nx.add_path(G, [1, 2, 3]) - nx.add_path(G, [4, 5]) - list(nx.node_disjoint_paths(G, 1, 5)) + with pytest.raises(nx.NetworkXNoPath): + G = nx.DiGraph() + nx.add_path(G, [1, 2, 3]) + nx.add_path(G, [4, 5]) + list(nx.node_disjoint_paths(G, 1, 5)) -@raises(nx.NetworkXNoPath) def test_not_connected_edges(): - G = nx.Graph() - nx.add_path(G, [1, 2, 3]) - nx.add_path(G, [4, 5]) - list(nx.edge_disjoint_paths(G, 1, 5)) + with pytest.raises(nx.NetworkXNoPath): + G = nx.Graph() + nx.add_path(G, [1, 2, 3]) + nx.add_path(G, [4, 5]) + list(nx.edge_disjoint_paths(G, 1, 5)) -@raises(nx.NetworkXNoPath) def test_not_connected_nodes(): - G = nx.Graph() - nx.add_path(G, [1, 2, 3]) - nx.add_path(G, [4, 5]) - list(nx.node_disjoint_paths(G, 1, 5)) + with pytest.raises(nx.NetworkXNoPath): + G = nx.Graph() + nx.add_path(G, [1, 2, 3]) + nx.add_path(G, [4, 5]) + list(nx.node_disjoint_paths(G, 1, 5)) -@raises(nx.NetworkXNoPath) def test_isolated_edges(): - G = nx.Graph() - G.add_node(1) - nx.add_path(G, [4, 5]) - list(nx.edge_disjoint_paths(G, 1, 5)) + with pytest.raises(nx.NetworkXNoPath): + G = nx.Graph() + G.add_node(1) + nx.add_path(G, [4, 5]) + list(nx.edge_disjoint_paths(G, 1, 5)) -@raises(nx.NetworkXNoPath) def test_isolated_nodes(): - G = nx.Graph() - G.add_node(1) - nx.add_path(G, [4, 5]) - list(nx.node_disjoint_paths(G, 1, 5)) + with pytest.raises(nx.NetworkXNoPath): + G = nx.Graph() + G.add_node(1) + nx.add_path(G, [4, 5]) + list(nx.node_disjoint_paths(G, 1, 5)) -@raises(nx.NetworkXError) def test_invalid_auxiliary(): - G = nx.complete_graph(5) - list(nx.node_disjoint_paths(G, 0, 3, auxiliary=G)) + with pytest.raises(nx.NetworkXError): + G = nx.complete_graph(5) + list(nx.node_disjoint_paths(G, 0, 3, auxiliary=G)) diff --git a/networkx/algorithms/connectivity/tests/test_kcomponents.py b/networkx/algorithms/connectivity/tests/test_kcomponents.py index bd6f55c9..f1160261 100644 --- a/networkx/algorithms/connectivity/tests/test_kcomponents.py +++ b/networkx/algorithms/connectivity/tests/test_kcomponents.py @@ -1,5 +1,5 @@ # Test for Moody and White k-components algorithm -from nose.tools import raises +import pytest import networkx as nx from networkx.algorithms.connectivity.kcomponents import ( build_k_number_dict, @@ -75,10 +75,10 @@ def torrents_and_ferraro_graph(): return G -@raises(nx.NetworkXNotImplemented) def test_directed(): - G = nx.gnp_random_graph(10, 0.2, directed=True, seed=42) - nx.k_components(G) + with pytest.raises(nx.NetworkXNotImplemented): + G = nx.gnp_random_graph(10, 0.2, directed=True, seed=42) + nx.k_components(G) # Helper function |