Skip to content

Commit b903081

Browse files
gfyoungjreback
authored andcommitted
MAINT: Remove nose dependency (#312)
1 parent 246f507 commit b903081

18 files changed

+95
-205
lines changed

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ install:
3030
- conda update -q conda
3131
# Useful for debugging any issues with conda
3232
- conda info -a
33-
- conda create -q -n test-environment python=$PYTHON pandas=$PANDAS nose coverage setuptools html5lib lxml pytest pytest-cov
33+
- conda create -q -n test-environment python=$PYTHON pandas=$PANDAS coverage setuptools html5lib lxml pytest pytest-cov
3434
- source activate test-environment
3535
- pip install beautifulsoup4
36-
- if [[ "$PYTHON" == "2.6" ]]; then
37-
pip install simplejson;
38-
fi
3936
- pip install coveralls --quiet
4037
- conda list
4138
- python setup.py install

pandas_datareader/tests/_utils.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

pandas_datareader/tests/test_base.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import nose
21
import pandas.util.testing as tm
32
import pandas_datareader.base as base
43

@@ -26,8 +25,3 @@ def test_get_params(self):
2625
with tm.assertRaises(NotImplementedError):
2726
b = base._DailyBaseReader()
2827
b._get_params()
29-
30-
31-
if __name__ == '__main__':
32-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
33-
exit=False)

pandas_datareader/tests/test_data.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
import nose
2-
3-
from pandas import DataFrame
4-
try:
5-
from pandas.util.testing import assert_produces_warning
6-
except ImportError: # pragma: no cover
7-
assert_produces_warning = None
8-
91
import pandas.util.testing as tm
10-
112
import pandas_datareader.data as web
3+
4+
from pandas import DataFrame
125
from pandas_datareader.data import DataReader
136

147

@@ -22,11 +15,8 @@ def tearDownClass(cls):
2215
super(TestOptionsWarnings, cls).tearDownClass()
2316

2417
def test_options_source_warning(self):
25-
if not assert_produces_warning: # pragma: no cover
26-
raise nose.SkipTest("old version of pandas without "
27-
"compat.assert_produces_warning")
28-
with assert_produces_warning():
29-
aapl = web.Options('aapl') # noqa
18+
with tm.assert_produces_warning():
19+
web.Options('aapl')
3020

3121

3222
class TestDataReader(tm.TestCase):
@@ -52,8 +42,3 @@ def test_read_fred(self):
5242

5343
def test_not_implemented(self):
5444
self.assertRaises(NotImplementedError, DataReader, "NA", "NA")
55-
56-
57-
if __name__ == '__main__':
58-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
59-
exit=False) # pragma: no cover

pandas_datareader/tests/test_edgar.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
import nose
1+
import pytest
22

33
import pandas as pd
44
import pandas.util.testing as tm
5-
65
import pandas_datareader.data as web
6+
77
from pandas_datareader._utils import RemoteDataError
88

99

1010
class TestEdgarIndex(tm.TestCase):
1111

12+
@classmethod
13+
def setup_class(cls):
14+
# As of December 31, SEC has disabled ftp access to EDGAR.
15+
# Disabling tests until re-write.
16+
pytest.skip("Disabling tests until re-write.")
17+
1218
def test_get_full_index(self):
13-
# As of December 31, SEC has disabled ftp access to EDGAR. Disabling tests until re-write
14-
raise nose.SkipTest()
1519
try:
1620
ed = web.DataReader('full', 'edgar-index')
1721
assert len(ed) > 1000
@@ -21,11 +25,9 @@ def test_get_full_index(self):
2125
tm.assert_index_equal(ed.columns, exp_columns)
2226

2327
except RemoteDataError as e:
24-
raise nose.SkipTest(e)
28+
pytest.skip(e)
2529

2630
def test_get_nonzip_index_and_low_date(self):
27-
# As of December 31, SEC has disabled ftp access to EDGAR. Disabling tests until re-write
28-
raise nose.SkipTest()
2931
try:
3032
ed = web.DataReader('daily', 'edgar-index', '1994-06-30',
3133
'1994-07-02')
@@ -39,21 +41,18 @@ def test_get_nonzip_index_and_low_date(self):
3941
tm.assert_index_equal(ed.columns, exp_columns)
4042

4143
except RemoteDataError as e:
42-
raise nose.SkipTest(e)
44+
pytest.skip(e)
4345

4446
def test_get_gz_index_and_no_date(self):
45-
# the test causes Travis timeout
46-
raise nose.SkipTest()
47+
# TODO: Rewrite, as this test causes Travis to timeout.
4748

4849
try:
4950
ed = web.DataReader('daily', 'edgar-index')
5051
assert len(ed) > 2000
5152
except RemoteDataError as e:
52-
raise nose.SkipTest(e)
53+
pytest.skip(e)
5354

5455
def test_6_digit_date(self):
55-
# As of December 31, SEC has disabled ftp access to EDGAR. Disabling tests until re-write
56-
raise nose.SkipTest()
5756
try:
5857
ed = web.DataReader('daily', 'edgar-index', start='1998-05-18',
5958
end='1998-05-18')
@@ -70,9 +69,4 @@ def test_6_digit_date(self):
7069
tm.assert_index_equal(ed.columns, exp_columns)
7170

7271
except RemoteDataError as e:
73-
raise nose.SkipTest(e)
74-
75-
76-
if __name__ == '__main__':
77-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
78-
exit=False)
72+
pytest.skip(e)
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import os
2+
import pytest
23

34
from requests.exceptions import HTTPError
45

5-
import nose
66
import pandas.util.testing as tm
7-
from pandas_datareader.tests._utils import _skip_if_no_lxml
87

9-
import pandas_datareader.data as web
108
import pandas_datareader as pdr
9+
import pandas_datareader.data as web
1110

1211
TEST_API_KEY = os.getenv('ENIGMA_API_KEY')
1312

@@ -17,23 +16,23 @@ class TestEnigma(tm.TestCase):
1716
@classmethod
1817
def setUpClass(cls):
1918
super(TestEnigma, cls).setUpClass()
20-
_skip_if_no_lxml()
19+
pytest.importorskip("lxml")
2120

2221
def test_enigma_datareader(self):
2322
try:
2423
df = web.DataReader('enigma.inspections.restaurants.fl',
2524
'enigma', access_key=TEST_API_KEY)
2625
self.assertTrue('serialid' in df.columns)
2726
except HTTPError as e: # pragma: no cover
28-
raise nose.SkipTest(e)
27+
pytest.skip(e)
2928

3029
def test_enigma_get_data_enigma(self):
3130
try:
3231
df = pdr.get_data_enigma(
3332
'enigma.inspections.restaurants.fl', TEST_API_KEY)
3433
self.assertTrue('serialid' in df.columns)
3534
except HTTPError as e: # pragma: no cover
36-
raise nose.SkipTest(e)
35+
pytest.skip(e)
3736

3837
def test_bad_key(self):
3938
with tm.assertRaises(HTTPError):
@@ -46,8 +45,3 @@ def test_bad_url(self):
4645
web.DataReader('enigma.inspections.restaurants.fllzzy',
4746
'enigma',
4847
access_key=TEST_API_KEY)
49-
50-
51-
if __name__ == '__main__':
52-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
53-
exit=False)

pandas_datareader/tests/test_eurostat.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import nose
2-
import sys
1+
import pytest
32

43
import numpy as np
54
import pandas as pd
@@ -11,12 +10,6 @@
1110

1211
class TestEurostat(tm.TestCase):
1312

14-
def setUp(self):
15-
16-
if sys.version_info < (2, 7, 0):
17-
raise nose.SkipTest("Doesn't support Python 2.6 because of"
18-
"ElementTree incompat")
19-
2013
def test_get_cdh_e_fos(self):
2114
# Employed doctorate holders in non managerial and non professional
2215
# occupations by fields of science (%)
@@ -72,10 +65,10 @@ def test_get_sts_cobp_a(self):
7265
tm.assert_series_equal(result, expected)
7366

7467
def test_get_nrg_pc_202(self):
75-
# GH 149
68+
# see gh-149
7669

7770
if not PANDAS_0170:
78-
raise nose.SkipTest("skip because of comparison failure")
71+
pytest.skip("skip because of comparison failure")
7972

8073
df = web.DataReader('nrg_pc_202', 'eurostat',
8174
start=pd.Timestamp('2010-01-01'),
@@ -97,14 +90,9 @@ def test_get_nrg_pc_202(self):
9790
tm.assert_series_equal(df[name], exp)
9891

9992
def test_get_prc_hicp_manr_exceeds_limit(self):
100-
# GH 149
93+
# see gh-149
10194
msg = 'Query size exceeds maximum limit'
10295
with tm.assertRaisesRegexp(ValueError, msg):
10396
web.DataReader('prc_hicp_manr', 'eurostat',
10497
start=pd.Timestamp('2000-01-01'),
10598
end=pd.Timestamp('2013-01-01'))
106-
107-
108-
if __name__ == '__main__':
109-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
110-
exit=False)

pandas_datareader/tests/test_famafrench.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import nose
1+
import pytest
2+
23
import pandas as pd
34
import pandas.util.testing as tm
45

56
import pandas_datareader.data as web
67
from pandas_datareader.famafrench import get_available_datasets
78

8-
from pandas_datareader.tests._utils import _skip_if_no_lxml
9-
109

1110
class TestFamaFrench(tm.TestCase):
1211

@@ -16,13 +15,14 @@ def test_get_data(self):
1615
'6_Portfolios_2x3', 'Portfolios_Formed_on_ME',
1716
'Prior_2-12_Breakpoints', 'ME_Breakpoints',
1817
]
18+
1919
for name in keys:
2020
ff = web.DataReader(name, 'famafrench')
2121
self.assertTrue('DESCR' in ff)
2222
self.assertTrue(len(ff) > 1)
2323

2424
def test_get_available_datasets(self):
25-
_skip_if_no_lxml()
25+
pytest.importorskip("lxml")
2626
l = get_available_datasets()
2727
self.assertTrue(len(l) > 100)
2828

@@ -80,8 +80,3 @@ def test_prior_2_12_breakpoints(self):
8080

8181
exp_index = pd.period_range('2010-01-01', '2010-12-01', freq='M', name='Date')
8282
tm.assert_index_equal(results[0].index, exp_index)
83-
84-
85-
if __name__ == '__main__':
86-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
87-
exit=False)

pandas_datareader/tests/test_fred.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
from datetime import datetime
22

3+
import pytest
4+
35
import numpy as np
46
import pandas as pd
5-
from pandas import DataFrame
7+
import pandas.util.testing as tm
68
import pandas_datareader.data as web
7-
from pandas_datareader._utils import RemoteDataError
89

9-
import nose
10-
import pandas.util.testing as tm
11-
from pandas.util.testing import assert_frame_equal
12-
from numpy.testing import assert_array_equal
10+
from pandas import DataFrame
11+
from pandas_datareader._utils import RemoteDataError
1312

1413

1514
class TestFred(tm.TestCase):
1615
def test_fred(self):
1716

18-
# Throws an exception when DataReader can't get a 200 response from
19-
# FRED.
17+
# Raises an exception when DataReader can't
18+
# get a 200 response from FRED.
2019

2120
start = datetime(2010, 1, 1)
2221
end = datetime(2013, 1, 1)
@@ -27,14 +26,8 @@ def test_fred(self):
2726
self.assertEqual(ts.index[-1], pd.to_datetime("2013-01-01"))
2827
self.assertEqual(ts.index.name, "DATE")
2928
self.assertEqual(ts.name, "GDP")
30-
received = ts.tail(1)[0]
3129

32-
# < 2014-07-30 16535 was returned
33-
# self.assertEqual(int(received), 16535)
34-
# < 2015-08-20 16502 was returned
35-
# self.assertEqual(int(received), 16502)
36-
# < 2016-08-01 16440 was returned
37-
# self.assertEqual(int(received), 16440)
30+
received = ts.tail(1)[0]
3831
self.assertEqual(int(received), 16475)
3932

4033
with tm.assertRaises(RemoteDataError):
@@ -46,9 +39,8 @@ def test_fred_nan(self):
4639
df = web.DataReader("DFII5", "fred", start, end)
4740
assert pd.isnull(df.ix['2010-01-01'][0])
4841

42+
@pytest.mark.skip(reason='Buggy as of 2/18/14; maybe a data revision?')
4943
def test_fred_parts(self): # pragma: no cover
50-
raise nose.SkipTest('buggy as of 2/18/14; maybe a data revision?')
51-
5244
start = datetime(2010, 1, 1)
5345
end = datetime(2013, 1, 27)
5446
df = web.get_data_fred("CPIAUCSL", start, end)
@@ -65,14 +57,14 @@ def test_fred_part2(self):
6557
[848.3],
6658
[933.3]]
6759
result = web.get_data_fred("A09024USA144NNBR", start="1915").ix[:5]
68-
assert_array_equal(result.values, np.array(expected))
60+
tm.assert_numpy_array_equal(result.values, np.array(expected))
6961

7062
def test_invalid_series(self):
7163
name = "NOT A REAL SERIES"
7264
self.assertRaises(Exception, web.get_data_fred, name)
7365

66+
@pytest.mark.skip(reason='Buggy as of 2/18/14; maybe a data revision?')
7467
def test_fred_multi(self): # pragma: no cover
75-
raise nose.SkipTest('buggy as of 2/18/14; maybe a data revision?')
7668
names = ['CPIAUCSL', 'CPALTT01USQ661S', 'CPILFESL']
7769
start = datetime(2010, 1, 1)
7870
end = datetime(2013, 1, 27)
@@ -81,14 +73,9 @@ def test_fred_multi(self): # pragma: no cover
8173
expected = DataFrame([[217.478, 0.99701529, 220.544]], columns=names,
8274
index=[pd.tslib.Timestamp('2010-01-01 00:00:00')])
8375
expected.index.rename('DATE', inplace=True)
84-
assert_frame_equal(received, expected, check_less_precise=True)
76+
tm.assert_frame_equal(received, expected, check_less_precise=True)
8577

8678
def test_fred_multi_bad_series(self):
8779
names = ['NOTAREALSERIES', 'CPIAUCSL', "ALSO FAKE"]
8880
with tm.assertRaises(RemoteDataError):
8981
web.DataReader(names, data_source="fred")
90-
91-
92-
if __name__ == '__main__':
93-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
94-
exit=False) # pragma: no cover

0 commit comments

Comments
 (0)