Skip to content

Commit 1cd4c63

Browse files
authored
TST: Remove test_pickle_generalurl_read in favor of test_request_headers (#60848)
Remove test_pickle_generalurl_read in favor of test_request_headers
1 parent dc315ee commit 1cd4c63

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

pandas/tests/io/test_pickle.py

-49
Original file line numberDiff line numberDiff line change
@@ -383,55 +383,6 @@ def test_pickle_buffer_roundtrip():
383383
tm.assert_frame_equal(df, result)
384384

385385

386-
# ---------------------
387-
# tests for URL I/O
388-
# ---------------------
389-
390-
391-
@pytest.mark.parametrize(
392-
"mockurl", ["http://url.com", "ftp://test.com", "http://gzip.com"]
393-
)
394-
def test_pickle_generalurl_read(monkeypatch, mockurl):
395-
def python_pickler(obj, path):
396-
with open(path, "wb") as fh:
397-
pickle.dump(obj, fh, protocol=-1)
398-
399-
class MockReadResponse:
400-
def __init__(self, path) -> None:
401-
self.file = open(path, "rb")
402-
if "gzip" in path:
403-
self.headers = {"Content-Encoding": "gzip"}
404-
else:
405-
self.headers = {"Content-Encoding": ""}
406-
407-
def __enter__(self):
408-
return self
409-
410-
def __exit__(self, *args):
411-
self.close()
412-
413-
def read(self):
414-
return self.file.read()
415-
416-
def close(self):
417-
return self.file.close()
418-
419-
with tm.ensure_clean() as path:
420-
421-
def mock_urlopen_read(*args, **kwargs):
422-
return MockReadResponse(path)
423-
424-
df = DataFrame(
425-
1.1 * np.arange(120).reshape((30, 4)),
426-
columns=Index(list("ABCD"), dtype=object),
427-
index=Index([f"i-{i}" for i in range(30)], dtype=object),
428-
)
429-
python_pickler(df, path)
430-
monkeypatch.setattr("urllib.request.urlopen", mock_urlopen_read)
431-
result = pd.read_pickle(mockurl)
432-
tm.assert_frame_equal(df, result)
433-
434-
435386
def test_pickle_fsspec_roundtrip():
436387
pytest.importorskip("fsspec")
437388
with tm.ensure_clean():

0 commit comments

Comments
 (0)