From 57a396be45832b1cd21a7c1ef8ed21d9451dffcc Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Fri, 20 Dec 2019 12:55:53 +0000 Subject: [PATCH 1/2] :fire: remove now-unnecessary td.skip_if_no(pathlib) --- pandas/tests/io/pytables/test_store.py | 1 - pandas/tests/io/sas/test_sas7bdat.py | 1 - pandas/tests/io/test_common.py | 1 - 3 files changed, 3 deletions(-) diff --git a/pandas/tests/io/pytables/test_store.py b/pandas/tests/io/pytables/test_store.py index d9a76fe97f813..f4668b0587f8a 100644 --- a/pandas/tests/io/pytables/test_store.py +++ b/pandas/tests/io/pytables/test_store.py @@ -4594,7 +4594,6 @@ def test_read_nokey_empty(self, setup_path): with pytest.raises(ValueError): read_hdf(path) - @td.skip_if_no("pathlib") def test_read_from_pathlib_path(self, setup_path): # GH11773 diff --git a/pandas/tests/io/sas/test_sas7bdat.py b/pandas/tests/io/sas/test_sas7bdat.py index e37561c865c7a..d08ceb57b10ea 100644 --- a/pandas/tests/io/sas/test_sas7bdat.py +++ b/pandas/tests/io/sas/test_sas7bdat.py @@ -68,7 +68,6 @@ def test_from_iterator(self): tm.assert_frame_equal(df, df0.iloc[2:5, :]) rdr.close() - @td.skip_if_no("pathlib") def test_path_pathlib(self): from pathlib import Path diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index a15eac89ecedb..37729ca73aea7 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -73,7 +73,6 @@ def test_expand_user_normal_path(self): assert expanded_name == filename assert os.path.expanduser(filename) == expanded_name - @td.skip_if_no("pathlib") def test_stringify_path_pathlib(self): rel_path = icom._stringify_path(Path(".")) assert rel_path == "." From ff447e2e295fc01585729546b492732eb75395fc Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Fri, 20 Dec 2019 13:59:47 +0000 Subject: [PATCH 2/2] :art: move imports to top --- pandas/tests/io/pytables/test_store.py | 3 +-- pandas/tests/io/sas/test_sas7bdat.py | 3 +-- pandas/tests/io/test_common.py | 10 ++-------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/pandas/tests/io/pytables/test_store.py b/pandas/tests/io/pytables/test_store.py index f4668b0587f8a..3cd9d9cdd67d2 100644 --- a/pandas/tests/io/pytables/test_store.py +++ b/pandas/tests/io/pytables/test_store.py @@ -3,6 +3,7 @@ from distutils.version import LooseVersion from io import BytesIO import os +from pathlib import Path import re from warnings import catch_warnings, simplefilter @@ -4597,8 +4598,6 @@ def test_read_nokey_empty(self, setup_path): def test_read_from_pathlib_path(self, setup_path): # GH11773 - from pathlib import Path - expected = DataFrame( np.random.rand(4, 5), index=list("abcd"), columns=list("ABCDE") ) diff --git a/pandas/tests/io/sas/test_sas7bdat.py b/pandas/tests/io/sas/test_sas7bdat.py index d08ceb57b10ea..49af18d2935ef 100644 --- a/pandas/tests/io/sas/test_sas7bdat.py +++ b/pandas/tests/io/sas/test_sas7bdat.py @@ -1,5 +1,6 @@ import io import os +from pathlib import Path import numpy as np import pytest @@ -69,8 +70,6 @@ def test_from_iterator(self): rdr.close() def test_path_pathlib(self): - from pathlib import Path - for j in 0, 1: df0 = self.data[j] for k in self.test_ix[j]: diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index 37729ca73aea7..d2633ea0676cd 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -4,6 +4,7 @@ from io import StringIO import mmap import os +from pathlib import Path import pytest @@ -27,14 +28,7 @@ def __fspath__(self): # Functions that consume a string path and return a string or path-like object -path_types = [str, CustomFSPath] - -try: - from pathlib import Path - - path_types.append(Path) -except ImportError: - pass +path_types = [str, CustomFSPath, Path] try: from py.path import local as LocalPath