diff --git a/pandas/io/tests/test_parsers.py b/pandas/io/tests/test_parsers.py index 1c8b7754c500f..8437875b17060 100644 --- a/pandas/io/tests/test_parsers.py +++ b/pandas/io/tests/test_parsers.py @@ -20,7 +20,7 @@ from pandas import DataFrame, Index, isnull from pandas.io.parsers import (read_csv, read_table, read_fwf, ExcelFile, TextParser) -from pandas.util.testing import assert_almost_equal, assert_frame_equal +from pandas.util.testing import assert_almost_equal, assert_frame_equal, network import pandas._tseries as lib from pandas.util import py3compat @@ -798,6 +798,7 @@ def test_na_value_dict(self): assert_frame_equal(df, expected) @slow + @network def test_url(self): # HTTP(S) url = 'https://raw.github.com/pydata/pandas/master/pandas/io/tests/salary.table' @@ -806,10 +807,20 @@ def test_url(self): localtable = os.path.join(dirpath, 'salary.table') local_table = read_table(localtable) assert_frame_equal(url_table, local_table) + #TODO: ftp testing + + @slow + def test_file(self): # FILE + if sys.version_info[:2] < (2, 6): + raise nose.SkipTest("file:// not supported with Python < 2.6") + dirpath = curpath() + localtable = os.path.join(dirpath, 'salary.table') + local_table = read_table(localtable) + url_table = read_table('file://localhost/'+localtable) assert_frame_equal(url_table, local_table) - #TODO: ftp testing + class TestParseSQL(unittest.TestCase): diff --git a/pandas/util/testing.py b/pandas/util/testing.py index 9552ed230d051..7a41b32baad0f 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -294,3 +294,40 @@ def skip_if_no_package(*args, **kwargs): package_check(exc_failed_import=SkipTest, exc_failed_check=SkipTest, *args, **kwargs) + +# +# Additional tags decorators for nose +# +def network(t): + """ + Label a test as requiring network connection. + + In some cases it is not possible to assume network presence (e.g. Debian + build hosts). + + Parameters + ---------- + t : callable + The test requiring network connectivity. + + Returns + ------- + t : callable + The decorated test `t`. + + Examples + -------- + A test can be decorated as requiring network like this:: + + from pandas.util.testing import * + + @network + def test_network(self): + print 'Fetch the stars from http://' + + And use ``nosetests -a '!network'`` to exclude running tests requiring + network connectivity. + """ + + t.network = True + return t