12
12
from pandas .util .testing import assert_frame_equal , assert_series_equal
13
13
try :
14
14
from pandas .util .testing import assert_produces_warning
15
- except ImportError :
15
+ except ImportError : # pragma: no cover
16
16
assert_produces_warning = None
17
17
18
18
import pandas .util .testing as tm
19
19
from numpy .testing import assert_array_equal
20
20
21
21
try :
22
22
from urllib .error import HTTPError
23
- except ImportError :
23
+ except ImportError : # pragma: no cover
24
24
from urllib2 import HTTPError
25
25
26
26
import pandas_datareader .data as web
30
30
def _skip_if_no_lxml ():
31
31
try :
32
32
import lxml
33
- except ImportError :
33
+ except ImportError : # pragma: no cover
34
34
raise nose .SkipTest ("no lxml" )
35
35
36
36
@@ -50,7 +50,7 @@ class TestGoogle(tm.TestCase):
50
50
def setUpClass (cls ):
51
51
super (TestGoogle , cls ).setUpClass ()
52
52
cls .locales = tm .get_locales (prefix = 'en_US' )
53
- if not cls .locales :
53
+ if not cls .locales : # pragma: no cover
54
54
raise nose .SkipTest ("US English locale not available for testing" )
55
55
56
56
@classmethod
@@ -92,7 +92,7 @@ def test_get_multi1(self):
92
92
if (hasattr (pan , 'Close' ) and hasattr (pan .Close , 'GOOG' ) and
93
93
hasattr (pan .Close , 'AAPL' )):
94
94
self .assertEqual (ts [0 ].dayofyear , 3 )
95
- else :
95
+ else : # pragma: no cover
96
96
self .assertRaises (AttributeError , lambda : pan .Close )
97
97
98
98
def test_get_multi_invalid (self ):
@@ -173,14 +173,14 @@ def test_get_quote_stringlist(self):
173
173
df = web .get_quote_yahoo (['GOOG' , 'AAPL' , 'GOOG' ])
174
174
assert_series_equal (df .ix [0 ], df .ix [2 ])
175
175
176
- def test_get_components_dow_jones (self ):
176
+ def test_get_components_dow_jones (self ): # pragma: no cover
177
177
raise nose .SkipTest ('unreliable test, receive partial components back for dow_jones' )
178
178
179
179
df = web .get_components_yahoo ('^DJI' ) #Dow Jones
180
180
assert isinstance (df , pd .DataFrame )
181
181
self .assertEqual (len (df ), 30 )
182
182
183
- def test_get_components_dax (self ):
183
+ def test_get_components_dax (self ): # pragma: no cover
184
184
raise nose .SkipTest ('unreliable test, receive partial components back for dax' )
185
185
186
186
df = web .get_components_yahoo ('^GDAXI' ) #DAX
@@ -189,7 +189,7 @@ def test_get_components_dax(self):
189
189
self .assertEqual (df [df .name .str .contains ('adidas' , case = False )].index ,
190
190
'ADS.DE' )
191
191
192
- def test_get_components_nasdaq_100 (self ):
192
+ def test_get_components_nasdaq_100 (self ): # pragma: no cover
193
193
# as of 7/12/13 the conditional will test false because the link is invalid
194
194
raise nose .SkipTest ('unreliable test, receive partial components back for nasdaq_100' )
195
195
@@ -298,8 +298,7 @@ def setUpClass(cls):
298
298
today = datetime .today ()
299
299
cls .year = today .year
300
300
cls .month = today .month + 1
301
- if cls .month > 12 :
302
- cls .year = cls .year + 1
301
+ if cls .month > 12 : # pragma: no cover
303
302
cls .month = 1
304
303
cls .expiry = datetime (cls .year , cls .month , 1 )
305
304
cls .dirpath = tm .get_data_path ()
@@ -320,57 +319,57 @@ def test_get_options_data(self):
320
319
321
320
try :
322
321
options = self .aapl .get_options_data (expiry = self .expiry )
323
- except RemoteDataError as e :
322
+ except RemoteDataError as e : # pragma: no cover
324
323
raise nose .SkipTest (e )
325
324
self .assertTrue (len (options ) > 1 )
326
325
327
326
def test_get_near_stock_price (self ):
328
327
try :
329
328
options = self .aapl .get_near_stock_price (call = True , put = True ,
330
329
expiry = self .expiry )
331
- except RemoteDataError as e :
330
+ except RemoteDataError as e : # pragma: no cover
332
331
raise nose .SkipTest (e )
333
332
self .assertTrue (len (options ) > 1 )
334
333
335
334
def test_get_call_data (self ):
336
335
try :
337
336
calls = self .aapl .get_call_data (expiry = self .expiry )
338
- except RemoteDataError as e :
337
+ except RemoteDataError as e : # pragma: no cover
339
338
raise nose .SkipTest (e )
340
339
self .assertTrue (len (calls ) > 1 )
341
340
342
341
def test_get_put_data (self ):
343
342
try :
344
343
puts = self .aapl .get_put_data (expiry = self .expiry )
345
- except RemoteDataError as e :
344
+ except RemoteDataError as e : # pragma: no cover
346
345
raise nose .SkipTest (e )
347
346
self .assertTrue (len (puts ) > 1 )
348
347
349
348
def test_get_expiry_dates (self ):
350
349
try :
351
350
dates , _ = self .aapl ._get_expiry_dates_and_links ()
352
- except RemoteDataError as e :
351
+ except RemoteDataError as e : # pragma: no cover
353
352
raise nose .SkipTest (e )
354
353
self .assertTrue (len (dates ) > 1 )
355
354
356
355
def test_get_all_data (self ):
357
356
try :
358
357
data = self .aapl .get_all_data (put = True )
359
- except RemoteDataError as e :
358
+ except RemoteDataError as e : # pragma: no cover
360
359
raise nose .SkipTest (e )
361
360
self .assertTrue (len (data ) > 1 )
362
361
363
362
def test_get_data_with_list (self ):
364
363
try :
365
364
data = self .aapl .get_call_data (expiry = self .aapl .expiry_dates )
366
- except RemoteDataError as e :
365
+ except RemoteDataError as e : # pragma: no cover
367
366
raise nose .SkipTest (e )
368
367
self .assertTrue (len (data ) > 1 )
369
368
370
369
def test_get_all_data_calls_only (self ):
371
370
try :
372
371
data = self .aapl .get_all_data (call = True , put = False )
373
- except RemoteDataError as e :
372
+ except RemoteDataError as e : # pragma: no cover
374
373
raise nose .SkipTest (e )
375
374
self .assertTrue (len (data ) > 1 )
376
375
@@ -381,7 +380,7 @@ def test_get_underlying_price(self):
381
380
url = options_object ._yahoo_url_from_expiry (options_object .expiry_dates [0 ])
382
381
root = options_object ._parse_url (url )
383
382
quote_price = options_object ._underlying_price_from_root (root )
384
- except RemoteDataError as e :
383
+ except RemoteDataError as e : # pragma: no cover
385
384
raise nose .SkipTest (e )
386
385
self .assert_ (isinstance (quote_price , float ))
387
386
@@ -419,7 +418,7 @@ def test_sample_page_chg_float(self):
419
418
def test_month_year (self ):
420
419
try :
421
420
data = self .aapl .get_call_data (month = self .month , year = self .year )
422
- except RemoteDataError as e :
421
+ except RemoteDataError as e : # pragma: no cover
423
422
raise nose .SkipTest (e )
424
423
425
424
self .assertTrue (len (data ) > 1 )
@@ -440,7 +439,7 @@ def tearDownClass(cls):
440
439
super (TestOptionsWarnings , cls ).tearDownClass ()
441
440
442
441
def test_options_source_warning (self ):
443
- if not assert_produces_warning :
442
+ if not assert_produces_warning : # pragma: no cover
444
443
raise nose .SkipTest ("old version of pandas without "
445
444
"compat.assert_produces_warning" )
446
445
with assert_produces_warning ():
@@ -499,7 +498,7 @@ def test_fred_nan(self):
499
498
df = web .DataReader ("DFII5" , "fred" , start , end )
500
499
assert pd .isnull (df .ix ['2010-01-01' ][0 ])
501
500
502
- def test_fred_parts (self ):
501
+ def test_fred_parts (self ): # pragma: no cover
503
502
raise nose .SkipTest ('buggy as of 2/18/14; maybe a data revision?' )
504
503
505
504
start = datetime (2010 , 1 , 1 )
@@ -524,9 +523,8 @@ def test_invalid_series(self):
524
523
name = "NOT A REAL SERIES"
525
524
self .assertRaises (Exception , web .get_data_fred , name )
526
525
527
- def test_fred_multi (self ):
526
+ def test_fred_multi (self ): # pragma: no cover
528
527
raise nose .SkipTest ('buggy as of 2/18/14; maybe a data revision?' )
529
-
530
528
names = ['CPIAUCSL' , 'CPALTT01USQ661S' , 'CPILFESL' ]
531
529
start = datetime (2010 , 1 , 1 )
532
530
end = datetime (2013 , 1 , 27 )
@@ -546,4 +544,4 @@ def test_fred_multi_bad_series(self):
546
544
547
545
if __name__ == '__main__' :
548
546
nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ],
549
- exit = False )
547
+ exit = False ) # pragma: no cover
0 commit comments