def test_stringify_path_localpath(self): tm._skip_if_no_localpath() path = os.path.join('foo', 'bar') abs_path = os.path.abspath(path) lpath = LocalPath(path) self.assertEqual(common._stringify_path(lpath), abs_path)
def test_path_localpath(self, dirpath, data_test_ix): from py.path import local as LocalPath df0, test_ix = data_test_ix for k in test_ix: fname = LocalPath(os.path.join(dirpath, f"test{k}.sas7bdat")) df = pd.read_sas(fname, encoding="utf-8") tm.assert_frame_equal(df, df0)
def test_path_localpath(self): from py.path import local as LocalPath for j in 0, 1: df0 = self.data[j] for k in self.test_ix[j]: fname = LocalPath(os.path.join( self.dirpath, "test{k}.sas7bdat".format(k=k))) df = pd.read_sas(fname, encoding='utf-8') tm.assert_frame_equal(df, df0)
def test_read_from_py_localpath(self, read_ext): # GH12655 from py.path import local as LocalPath str_path = os.path.join('test1' + read_ext) expected = pd.read_excel(str_path, 'Sheet1', index_col=0) path_obj = LocalPath().join('test1' + read_ext) actual = pd.read_excel(path_obj, 'Sheet1', index_col=0) tm.assert_frame_equal(expected, actual)
def collect_picks(*picks, **handler_kwargs): """Extract and collect relevant items from dumped pickle data. Return a dict with these items:: config: module dict parts: fs path components corresponding to /uri command: HTTP verb path: full /uri including query, etc. auth_dict: (when nonempty) GIT_PROJECT_ROOT: '{docroot}/rest' PATH_INFO: '/repo.git/...' PATH_TRANSLATED: the previous two combined QUERY_STRING: 'service=...' or '' GIT_NAMESPACE: when set ... """ import pickle from py.path import local as LocalPath from conftest import replace_all if not isinstance(picks[0], LocalPath): picks = [LocalPath(str(p)) for p in picks] collected = {} reps = (("-__-", "-"), ("-__", ""), ("__-", ""), ("test_", "")) # FIXME remove auth stuff; it DOES impact path translation skip = ("ssl-", "-ssl", ".ssl", "auth-", "-auth", ".auth") for pick in picks: _tname = pick.parts()[-2].basename.replace("srv-", "") # Skip TLS-related variants if any(s in _tname for s in skip): continue with pick.open("rb") as flor: calls = pickle.load(flor) tname = replace_all(_tname, reps).rstrip("0123456789._") collected[tname] = [] handler = None for call in calls: if handler is None: handler = CallHandler(**handler_kwargs) res = handler(call) if res is not None: collected[tname].append(res) handler = None return collected
def test_read_from_py_localpath(setup_path): # GH11773 from py.path import local as LocalPath expected = DataFrame(np.random.rand(4, 5), index=list("abcd"), columns=list("ABCDE")) with ensure_clean_path(setup_path) as filename: path_obj = LocalPath(filename) expected.to_hdf(path_obj, "df", mode="a") actual = read_hdf(path_obj, "df") tm.assert_frame_equal(expected, actual)
def test_stringify_path_localpath(self): path = os.path.join("foo", "bar") abs_path = os.path.abspath(path) lpath = LocalPath(path) assert icom.stringify_path(lpath) == abs_path
def test_stringify_path_localpath(self): path = os.path.join('foo', 'bar') abs_path = os.path.abspath(path) lpath = LocalPath(path) assert icom._stringify_path(lpath) == abs_path
def fixtures() -> Path: here = abspath(dirname(__file__)) return LocalPath(join(here, "fixtures"))