diff --git a/fsspec/tests/abstract/common.py b/fsspec/tests/abstract/common.py new file mode 100644 index 000000000..93896a443 --- /dev/null +++ b/fsspec/tests/abstract/common.py @@ -0,0 +1,175 @@ +GLOB_EDGE_CASES_TESTS = { + "argnames": ("path", "recursive", "maxdepth", "expected"), + "argvalues": [ + ("fil?1", False, None, ["file1"]), + ("fil?1", True, None, ["file1"]), + ("file[1-2]", False, None, ["file1", "file2"]), + ("file[1-2]", True, None, ["file1", "file2"]), + ("*", False, None, ["file1", "file2"]), + ( + "*", + True, + None, + [ + "file1", + "file2", + "subdir0/subfile1", + "subdir0/subfile2", + "subdir0/nesteddir/nestedfile", + "subdir1/subfile1", + "subdir1/subfile2", + "subdir1/nesteddir/nestedfile", + ], + ), + ("*", True, 1, ["file1", "file2"]), + ( + "*", + True, + 2, + [ + "file1", + "file2", + "subdir0/subfile1", + "subdir0/subfile2", + "subdir1/subfile1", + "subdir1/subfile2", + ], + ), + ("*1", False, None, ["file1"]), + ( + "*1", + True, + None, + [ + "file1", + "subdir1/subfile1", + "subdir1/subfile2", + "subdir1/nesteddir/nestedfile", + ], + ), + ("*1", True, 2, ["file1", "subdir1/subfile1", "subdir1/subfile2"]), + ( + "**", + False, + None, + [ + "file1", + "file2", + "subdir0/subfile1", + "subdir0/subfile2", + "subdir0/nesteddir/nestedfile", + "subdir1/subfile1", + "subdir1/subfile2", + "subdir1/nesteddir/nestedfile", + ], + ), + ( + "**", + True, + None, + [ + "file1", + "file2", + "subdir0/subfile1", + "subdir0/subfile2", + "subdir0/nesteddir/nestedfile", + "subdir1/subfile1", + "subdir1/subfile2", + "subdir1/nesteddir/nestedfile", + ], + ), + ("**", True, 1, ["file1", "file2"]), + ( + "**", + True, + 2, + [ + "file1", + "file2", + "subdir0/subfile1", + "subdir0/subfile2", + "subdir0/nesteddir/nestedfile", + "subdir1/subfile1", + "subdir1/subfile2", + "subdir1/nesteddir/nestedfile", + ], + ), + ( + "**", + False, + 2, + [ + "file1", + "file2", + "subdir0/subfile1", + "subdir0/subfile2", + "subdir1/subfile1", + "subdir1/subfile2", + ], + ), + ("**1", False, None, ["file1", "subdir0/subfile1", "subdir1/subfile1"]), + ( + "**1", + True, + None, + [ + "file1", + "subdir0/subfile1", + "subdir1/subfile1", + "subdir1/subfile2", + "subdir1/nesteddir/nestedfile", + ], + ), + ("**1", True, 1, ["file1"]), + ( + "**1", + True, + 2, + ["file1", "subdir0/subfile1", "subdir1/subfile1", "subdir1/subfile2"], + ), + ("**1", False, 2, ["file1", "subdir0/subfile1", "subdir1/subfile1"]), + ("**/subdir0", False, None, []), + ("**/subdir0", True, None, ["subfile1", "subfile2", "nesteddir/nestedfile"]), + ("**/subdir0/nested*", False, 2, []), + ("**/subdir0/nested*", True, 2, ["nestedfile"]), + ("subdir[1-2]", False, None, []), + ("subdir[1-2]", True, None, ["subfile1", "subfile2", "nesteddir/nestedfile"]), + ("subdir[1-2]", True, 2, ["subfile1", "subfile2"]), + ("subdir[0-1]", False, None, []), + ( + "subdir[0-1]", + True, + None, + [ + "subdir0/subfile1", + "subdir0/subfile2", + "subdir0/nesteddir/nestedfile", + "subdir1/subfile1", + "subdir1/subfile2", + "subdir1/nesteddir/nestedfile", + ], + ), + ( + "subdir[0-1]/*fil[e]*", + False, + None, + [ + "subdir0/subfile1", + "subdir0/subfile2", + "subdir1/subfile1", + "subdir1/subfile2", + ], + ), + ( + "subdir[0-1]/*fil[e]*", + True, + None, + [ + "subdir0/subfile1", + "subdir0/subfile2", + "subdir1/subfile1", + "subdir1/subfile2", + ], + ), + ], +} diff --git a/fsspec/tests/abstract/copy.py b/fsspec/tests/abstract/copy.py index 8f0d6d0ba..400083107 100644 --- a/fsspec/tests/abstract/copy.py +++ b/fsspec/tests/abstract/copy.py @@ -2,7 +2,7 @@ import pytest -from fsspec.tests.conftest import GLOB_EDGE_CASES_TESTS +from fsspec.tests.abstract.common import GLOB_EDGE_CASES_TESTS class AbstractCopyTests: diff --git a/fsspec/tests/abstract/get.py b/fsspec/tests/abstract/get.py index 3c2711467..1752c1adf 100644 --- a/fsspec/tests/abstract/get.py +++ b/fsspec/tests/abstract/get.py @@ -3,7 +3,7 @@ import pytest from fsspec.implementations.local import make_path_posix -from fsspec.tests.conftest import GLOB_EDGE_CASES_TESTS +from fsspec.tests.abstract.common import GLOB_EDGE_CASES_TESTS class AbstractGetTests: diff --git a/fsspec/tests/abstract/put.py b/fsspec/tests/abstract/put.py index ad30ecbef..54506c081 100644 --- a/fsspec/tests/abstract/put.py +++ b/fsspec/tests/abstract/put.py @@ -2,7 +2,7 @@ import pytest -from fsspec.tests.conftest import GLOB_EDGE_CASES_TESTS +from fsspec.tests.abstract.common import GLOB_EDGE_CASES_TESTS class AbstractPutTests: diff --git a/fsspec/tests/conftest.py b/fsspec/tests/conftest.py index 544e8a0e0..2c7a1742b 100644 --- a/fsspec/tests/conftest.py +++ b/fsspec/tests/conftest.py @@ -18,182 +18,6 @@ ).read() win = os.name == "nt" -GLOB_EDGE_CASES_TESTS = { - "argnames": ("path", "recursive", "maxdepth", "expected"), - "argvalues": [ - ("fil?1", False, None, ["file1"]), - ("fil?1", True, None, ["file1"]), - ("file[1-2]", False, None, ["file1", "file2"]), - ("file[1-2]", True, None, ["file1", "file2"]), - ("*", False, None, ["file1", "file2"]), - ( - "*", - True, - None, - [ - "file1", - "file2", - "subdir0/subfile1", - "subdir0/subfile2", - "subdir0/nesteddir/nestedfile", - "subdir1/subfile1", - "subdir1/subfile2", - "subdir1/nesteddir/nestedfile", - ], - ), - ("*", True, 1, ["file1", "file2"]), - ( - "*", - True, - 2, - [ - "file1", - "file2", - "subdir0/subfile1", - "subdir0/subfile2", - "subdir1/subfile1", - "subdir1/subfile2", - ], - ), - ("*1", False, None, ["file1"]), - ( - "*1", - True, - None, - [ - "file1", - "subdir1/subfile1", - "subdir1/subfile2", - "subdir1/nesteddir/nestedfile", - ], - ), - ("*1", True, 2, ["file1", "subdir1/subfile1", "subdir1/subfile2"]), - ( - "**", - False, - None, - [ - "file1", - "file2", - "subdir0/subfile1", - "subdir0/subfile2", - "subdir0/nesteddir/nestedfile", - "subdir1/subfile1", - "subdir1/subfile2", - "subdir1/nesteddir/nestedfile", - ], - ), - ( - "**", - True, - None, - [ - "file1", - "file2", - "subdir0/subfile1", - "subdir0/subfile2", - "subdir0/nesteddir/nestedfile", - "subdir1/subfile1", - "subdir1/subfile2", - "subdir1/nesteddir/nestedfile", - ], - ), - ("**", True, 1, ["file1", "file2"]), - ( - "**", - True, - 2, - [ - "file1", - "file2", - "subdir0/subfile1", - "subdir0/subfile2", - "subdir0/nesteddir/nestedfile", - "subdir1/subfile1", - "subdir1/subfile2", - "subdir1/nesteddir/nestedfile", - ], - ), - ( - "**", - False, - 2, - [ - "file1", - "file2", - "subdir0/subfile1", - "subdir0/subfile2", - "subdir1/subfile1", - "subdir1/subfile2", - ], - ), - ("**1", False, None, ["file1", "subdir0/subfile1", "subdir1/subfile1"]), - ( - "**1", - True, - None, - [ - "file1", - "subdir0/subfile1", - "subdir1/subfile1", - "subdir1/subfile2", - "subdir1/nesteddir/nestedfile", - ], - ), - ("**1", True, 1, ["file1"]), - ( - "**1", - True, - 2, - ["file1", "subdir0/subfile1", "subdir1/subfile1", "subdir1/subfile2"], - ), - ("**1", False, 2, ["file1", "subdir0/subfile1", "subdir1/subfile1"]), - ("**/subdir0", False, None, []), - ("**/subdir0", True, None, ["subfile1", "subfile2", "nesteddir/nestedfile"]), - ("**/subdir0/nested*", False, 2, []), - ("**/subdir0/nested*", True, 2, ["nestedfile"]), - ("subdir[1-2]", False, None, []), - ("subdir[1-2]", True, None, ["subfile1", "subfile2", "nesteddir/nestedfile"]), - ("subdir[1-2]", True, 2, ["subfile1", "subfile2"]), - ("subdir[0-1]", False, None, []), - ( - "subdir[0-1]", - True, - None, - [ - "subdir0/subfile1", - "subdir0/subfile2", - "subdir0/nesteddir/nestedfile", - "subdir1/subfile1", - "subdir1/subfile2", - "subdir1/nesteddir/nestedfile", - ], - ), - ( - "subdir[0-1]/*fil[e]*", - False, - None, - [ - "subdir0/subfile1", - "subdir0/subfile2", - "subdir1/subfile1", - "subdir1/subfile2", - ], - ), - ( - "subdir[0-1]/*fil[e]*", - True, - None, - [ - "subdir0/subfile1", - "subdir0/subfile2", - "subdir1/subfile1", - "subdir1/subfile2", - ], - ), - ], -} - @pytest.fixture def reset_files():