From 3b9104f40dc949ec1f5c83718f9238d55b1429e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20R=C3=B6sner?= Date: Thu, 9 Nov 2023 09:00:41 +0100 Subject: [PATCH] test: add tests for pathlib.Path. --- fsspec/tests/test_utils.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/fsspec/tests/test_utils.py b/fsspec/tests/test_utils.py index b5732e9f1..c7bad93bc 100644 --- a/fsspec/tests/test_utils.py +++ b/fsspec/tests/test_utils.py @@ -1,5 +1,6 @@ import io import sys +from pathlib import Path from unittest.mock import Mock import pytest @@ -8,6 +9,7 @@ from fsspec.utils import ( can_be_local, common_prefix, + get_protocol, infer_storage_options, merge_offset_ranges, mirror_from, @@ -333,6 +335,24 @@ def test_log(): assert logger.level == logging.DEBUG +@pytest.mark.parametrize( + "par", + [ + ("afile", "file"), + ("file://afile", "file"), + ("noproto://afile", "noproto"), + ("noproto::stuff", "noproto"), + ("simplecache::stuff", "simplecache"), + ("simplecache://stuff", "simplecache"), + ("s3://afile", "s3"), + (Path("afile"), "file"), + ], +) +def test_get_protocol(par): + url, outcome = par + assert get_protocol(url) == outcome + + @pytest.mark.parametrize( "par", [ @@ -342,6 +362,7 @@ def test_log(): ("noproto::stuff", False), ("simplecache::stuff", True), ("simplecache://stuff", True), + (Path("afile"), True), ], ) def test_can_local(par):