Repository: statsmodels/statsmodels

Issue:
TST disable test_webuse again
 see #2233

one file is being downloaded from sourceforge which has frequent connection problems
the download from our source on github worked without problems

But I want to get 0.7 out instead of being distracted by network problems



Discussion:
[![Coverage Status](https://coveralls.io/builds/1938950/badge)](https://coveralls.io/builds/1938950)

Coverage decreased (-0.04%) to 83.91% when pulling **6b25ad8d4ebf55fd94c4a6ec1cd77d4bb906a5bb on josef-pkt:disable_webuse_test** into **c2383e596e792cd1eea1320f3e16242038c3aca4 on statsmodels:master**.


Resolving patch:
diff --git a/statsmodels/datasets/utils.py b/statsmodels/datasets/utils.py
--- a/statsmodels/datasets/utils.py
+++ b/statsmodels/datasets/utils.py
@@ -329,10 +329,11 @@ def clear_data_home(data_home=None):
     data_home = get_data_home(data_home)
     shutil.rmtree(data_home)
 
-def check_internet():
+def check_internet(url=None):
     """Check if internet is available"""
+    url = "https://github.com" if url is None else url
     try:
-        urlopen("https://github.com")
+        urlopen(url)
     except URLError as err:
         return False
     return True


Test patch:
diff --git a/statsmodels/datasets/tests/test_utils.py b/statsmodels/datasets/tests/test_utils.py
--- a/statsmodels/datasets/tests/test_utils.py
+++ b/statsmodels/datasets/tests/test_utils.py
@@ -1,38 +1,48 @@
 from statsmodels.compat.python import PY3
 import os
-from statsmodels.datasets import get_rdataset, webuse, check_internet
+
+from nose import SkipTest
 from numpy.testing import assert_, assert_array_equal, dec
 
+from statsmodels.datasets import get_rdataset, webuse, check_internet, utils
+
 cur_dir = os.path.dirname(os.path.abspath(__file__))
 
-dec.skipif(PY3, 'Not testable on Python 3.x')
 def test_get_rdataset():
     # smoke test
+    test_url = "https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/cars.csv"
+    internet_available = check_internet(test_url)
+    if not internet_available:
+        raise SkipTest('Unable to retrieve file - skipping test')
+    duncan = get_rdataset("Duncan", "car", cache=cur_dir)
+    assert_(isinstance(duncan, utils.Dataset))
     if not PY3:
         #NOTE: there's no way to test both since the cached files were
         #created with Python 2.x, they're strings, but Python 3 expects
         #bytes and the index file path is hard-coded so both can't live
         #side by side
-        duncan = get_rdataset("Duncan", "car", cache=cur_dir)
         assert_(duncan.from_cache)
 
-#internet_available = check_internet()
-#@dec.skipif(not internet_available)
-def t_est_webuse():
+def test_webuse():
     # test copied and adjusted from iolib/tests/test_foreign
     from statsmodels.iolib.tests.results.macrodata import macrodata_result as res2
-    #base_gh = "http://github.com/statsmodels/statsmodels/raw/master/statsmodels/datasets/macrodata/"
-    base_gh = "http://www.statsmodels.org/devel/_static/"
+    base_gh = "http://github.com/statsmodels/statsmodels/raw/master/statsmodels/datasets/macrodata/"
+    internet_available = check_internet(base_gh)
+    if not internet_available:
+        raise SkipTest('Unable to retrieve file - skipping test')
     res1 = webuse('macrodata', baseurl=base_gh, as_df=False)
-    assert_array_equal(res1 == res2, True)
+    assert_array_equal(res1, res2)
+
 
-#@dec.skipif(not internet_available)
-def t_est_webuse_pandas():
+def test_webuse_pandas():
     # test copied and adjusted from iolib/tests/test_foreign
     from pandas.util.testing import assert_frame_equal
     from statsmodels.datasets import macrodata
     dta = macrodata.load_pandas().data
     base_gh = "http://github.com/statsmodels/statsmodels/raw/master/statsmodels/datasets/macrodata/"
+    internet_available = check_internet(base_gh)
+    if not internet_available:
+        raise SkipTest('Unable to retrieve file - skipping test')
     res1 = webuse('macrodata', baseurl=base_gh)
     res1 = res1.astype(float)
     assert_frame_equal(res1, dta)