diff options
author | Dan Schult <dschult@colgate.edu> | 2019-10-10 11:14:04 -0400 |
---|---|---|
committer | Jarrod Millman <jarrod.millman@gmail.com> | 2019-10-12 09:26:31 -0700 |
commit | aa5ff1d4d4f839e53be39df6ef8de19950b80c34 (patch) | |
tree | acf8fb1d8eb44f6f3dedc7a373d81a1454f6de84 /networkx/tests | |
parent | 9b8e6f1a70baef0e3a0b43580f1ebd3f31cfcec5 (diff) | |
download | networkx-aa5ff1d4d4f839e53be39df6ef8de19950b80c34.tar.gz |
More doctest corrections
Diffstat (limited to 'networkx/tests')
-rw-r--r-- | networkx/tests/test_convert_pandas.py | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/networkx/tests/test_convert_pandas.py b/networkx/tests/test_convert_pandas.py index 51b5d51c..0744b100 100644 --- a/networkx/tests/test_convert_pandas.py +++ b/networkx/tests/test_convert_pandas.py @@ -1,6 +1,5 @@ import pytest pd = pytest.importorskip("pandas") -from nose.tools import assert_raises import networkx as nx from networkx.testing import assert_nodes_equal, assert_edges_equal, \ @@ -8,14 +7,6 @@ from networkx.testing import assert_nodes_equal, assert_edges_equal, \ class TestConvertPandas(object): -# @classmethod -# def setup_class(cls): -# global pd -# try: -# import pandas as pd -# except ImportError: -# raise SkipTest('Pandas not available.') - def setup_method(self): self.rng = pd.np.random.RandomState(seed=5) ints = self.rng.randint(1, 11, size=(3, 2)) @@ -32,12 +23,12 @@ class TestConvertPandas(object): def test_exceptions(self): G = pd.DataFrame(["a"]) # adj - assert_raises(nx.NetworkXError, nx.to_networkx_graph, G) + pytest.raises(nx.NetworkXError, nx.to_networkx_graph, G) G = pd.DataFrame(["a", 0.0]) # elist - assert_raises(nx.NetworkXError, nx.to_networkx_graph, G) + pytest.raises(nx.NetworkXError, nx.to_networkx_graph, G) df = pd.DataFrame([[1, 1], [1, 0]], dtype=int, index=[1, 2], columns=["a", "b"]) - assert_raises(nx.NetworkXError, nx.from_pandas_adjacency, df) + pytest.raises(nx.NetworkXError, nx.from_pandas_adjacency, df) def test_from_edgelist_all_attr(self): Gtrue = nx.Graph([('E', 'C', {'cost': 9, 'weight': 10}), @@ -109,17 +100,17 @@ class TestConvertPandas(object): assert_graphs_equal(G, Gtrue) def test_from_edgelist_invalid_attr(self): - assert_raises(nx.NetworkXError, nx.from_pandas_edgelist, + pytest.raises(nx.NetworkXError, nx.from_pandas_edgelist, self.df, 0, 'b', 'misspell') - assert_raises(nx.NetworkXError, nx.from_pandas_edgelist, + pytest.raises(nx.NetworkXError, nx.from_pandas_edgelist, self.df, 0, 'b', 1) # see Issue #3562 edgeframe = pd.DataFrame([[0, 1], [1, 2], [2, 0]], columns=['s', 't']) - assert_raises(nx.NetworkXError, nx.from_pandas_edgelist, + pytest.raises(nx.NetworkXError, nx.from_pandas_edgelist, edgeframe, 's', 't', True) - assert_raises(nx.NetworkXError, nx.from_pandas_edgelist, + pytest.raises(nx.NetworkXError, nx.from_pandas_edgelist, edgeframe, 's', 't', 'weight') - assert_raises(nx.NetworkXError, nx.from_pandas_edgelist, + pytest.raises(nx.NetworkXError, nx.from_pandas_edgelist, edgeframe, 's', 't', ['weight', 'size']) def test_from_edgelist_no_attr(self): |