Skip to content

Commit b0c5072

Browse files
committed
Localpath skip decorator
1 parent a36e7ca commit b0c5072

File tree

6 files changed

+9
-19
lines changed

6 files changed

+9
-19
lines changed

pandas/tests/io/sas/test_sas7bdat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def test_path_pathlib(self):
8383
df = pd.read_sas(fname, encoding='utf-8')
8484
tm.assert_frame_equal(df, df0)
8585

86+
@td.skip_if_no('py.path')
8687
def test_path_localpath(self):
87-
tm._skip_if_no_localpath()
8888
from py.path import local as LocalPath
8989
for j in 0, 1:
9090
df0 = self.data[j]

pandas/tests/io/test_common.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ def test_stringify_path_pathlib(self):
7575
redundant_path = common._stringify_path(Path('foo//bar'))
7676
assert redundant_path == os.path.join('foo', 'bar')
7777

78+
@td.skip_if_no('py.path')
7879
def test_stringify_path_localpath(self):
79-
tm._skip_if_no_localpath()
80-
8180
path = os.path.join('foo', 'bar')
8281
abs_path = os.path.abspath(path)
8382
lpath = LocalPath(path)

pandas/tests/io/test_excel.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,10 @@ def test_read_from_pathlib_path(self):
665665

666666
tm.assert_frame_equal(expected, actual)
667667

668+
@td.skip_if_no('py.path')
668669
def test_read_from_py_localpath(self):
669670

670671
# GH12655
671-
tm._skip_if_no_localpath()
672-
673672
from py.path import local as LocalPath
674673

675674
str_path = os.path.join(self.dirpath, 'test1' + self.ext)

pandas/tests/io/test_pytables.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -5119,11 +5119,10 @@ def test_read_nokey_empty(self):
51195119
store.close()
51205120
pytest.raises(ValueError, read_hdf, path)
51215121

5122+
@td.skip_if_no('pathlib')
51225123
def test_read_from_pathlib_path(self):
51235124

51245125
# GH11773
5125-
tm._skip_if_no_pathlib()
5126-
51275126
from pathlib import Path
51285127

51295128
expected = DataFrame(np.random.rand(4, 5),
@@ -5137,11 +5136,10 @@ def test_read_from_pathlib_path(self):
51375136

51385137
tm.assert_frame_equal(expected, actual)
51395138

5139+
@td.skip_if_no('py.path')
51405140
def test_read_from_py_localpath(self):
51415141

51425142
# GH11773
5143-
tm._skip_if_no_localpath()
5144-
51455143
from py.path import local as LocalPath
51465144

51475145
expected = DataFrame(np.random.rand(4, 5),

pandas/util/_test_decorators.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ def _skip_if_not_us_locale():
9696

9797
def skip_if_no(package, min_version=None):
9898
def decorated_func(func):
99-
return pytest.mark.skipif(not safe_import(package, min_version=min_version),
100-
reason="Could not import '{}'".format(package))(func)
99+
return pytest.mark.skipif(
100+
not safe_import(package, min_version=min_version),
101+
reason="Could not import '{}'".format(package)
102+
)(func)
101103
return decorated_func
102104

103105

pandas/util/testing.py

-8
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,6 @@ def _skip_if_no_xarray():
359359
pytest.skip("xarray version is too low: {version}".format(version=v))
360360

361361

362-
def _skip_if_no_localpath():
363-
try:
364-
from py.path import local as LocalPath # noqa
365-
except ImportError:
366-
import pytest
367-
pytest.skip("py.path not installed")
368-
369-
370362
def skip_if_no_ne(engine='numexpr'):
371363
from pandas.core.computation.expressions import (
372364
_USE_NUMEXPR,

0 commit comments

Comments
 (0)