Repository: pandas-dev/pandas

Issue:
TST: get options issue
https://travis-ci.org/pydata/pandas/jobs/28313605

@cpcloud 

cc @dstephens99



Discussion:

Resolving patch:
diff --git a/pandas/io/data.py b/pandas/io/data.py
--- a/pandas/io/data.py
+++ b/pandas/io/data.py
@@ -680,6 +680,10 @@ def _get_option_tables(self, month, year, expiry):
 
         root = self._parse_url(url)
         tables = root.xpath('.//table')
+        ntables = len(tables)
+        if ntables == 0:
+            raise RemoteDataError("No tables found at {0!r}".format(url))
+
         table_name = '_tables' + m1 + str(year)[-2:]
         setattr(self, table_name, tables)
 
@@ -723,9 +727,7 @@ def _get_option_data(self, month, year, expiry, name):
 
         ntables = len(tables)
         table_loc = self._TABLE_LOC[name]
-        if ntables == 0:
-            raise RemoteDataError("No tables found at {0!r}".format(url))
-        elif table_loc - 1 > ntables:
+        if table_loc - 1 > ntables:
             raise RemoteDataError("Table location {0} invalid, {1} tables"
                              " found".format(table_loc, ntables))
 


Test patch:
diff --git a/pandas/io/tests/test_data.py b/pandas/io/tests/test_data.py
--- a/pandas/io/tests/test_data.py
+++ b/pandas/io/tests/test_data.py
@@ -266,8 +266,7 @@ def test_get_options_data(self):
             options = self.aapl.get_options_data(expiry=self.expiry)
         except RemoteDataError as e:
             nose.SkipTest(e)
-        else:
-            assert len(options) > 1
+        self.assertTrue(len(options) > 1)
 
     @network
     def test_get_near_stock_price(self):
@@ -276,9 +275,6 @@ def test_get_near_stock_price(self):
                                                      expiry=self.expiry)
         except RemoteDataError as e:
             nose.SkipTest(e)
-        else:
-            assert len(options) > 1
-
         self.assertTrue(len(options) > 1)
 
     @network
@@ -287,8 +283,7 @@ def test_get_call_data(self):
             calls = self.aapl.get_call_data(expiry=self.expiry)
         except RemoteDataError as e:
             nose.SkipTest(e)
-        else:
-            assert len(calls) > 1
+        self.assertTrue(len(calls) > 1)
 
     @network
     def test_get_put_data(self):
@@ -296,33 +291,30 @@ def test_get_put_data(self):
             puts = self.aapl.get_put_data(expiry=self.expiry)
         except RemoteDataError as e:
             nose.SkipTest(e)
-        else:
-            assert len(puts) > 1
+        self.assertTrue(len(puts) > 1)
 
     @network
     def test_get_expiry_months(self):
         try:
             dates = self.aapl._get_expiry_months()
-        except RemoteDataError:
-            raise nose.SkipTest("RemoteDataError thrown no dates found")
+        except RemoteDataError as e:
+            raise nose.SkipTest(e)
         self.assertTrue(len(dates) > 1)
 
     @network
     def test_get_all_data(self):
         try:
             data = self.aapl.get_all_data(put=True)
-        except RemoteDataError:
-            raise nose.SkipTest("RemoteDataError thrown")
-
+        except RemoteDataError as e:
+            raise nose.SkipTest(e)
         self.assertTrue(len(data) > 1)
 
     @network
     def test_get_all_data_calls_only(self):
         try:
             data = self.aapl.get_all_data(call=True, put=False)
-        except RemoteDataError:
-            raise nose.SkipTest("RemoteDataError thrown")
-
+        except RemoteDataError as e:
+            raise nose.SkipTest(e)
         self.assertTrue(len(data) > 1)
 
     @network