Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbull committed Oct 8, 2023
1 parent d006287 commit 921f84e
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions tests/test_cloudpath_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path, PurePosixPath
import pickle
from shutil import rmtree
import sys
from time import sleep

import pytest
Expand Down Expand Up @@ -129,8 +130,8 @@ def _assert_walk_results_match(cloud_results, local_results, cloud_root, local_r
Path(local_item).as_posix(), local_root
)

assert cloud_dirs == local_dirs
assert local_files == cloud_files
assert set(cloud_dirs) == set(local_dirs) # order not guaranteed
assert set(local_files) == set(cloud_files) # order not guaranteed


def test_iterdir(glob_test_dirs):
Expand Down Expand Up @@ -188,10 +189,10 @@ def test_glob(glob_test_dirs):
# cases adapted from CPython glob tests:
# https://github.com/python/cpython/blob/7ffe7ba30fc051014977c6f393c51e57e71a6648/Lib/test/test_pathlib.py#L1634-L1720

def _check_glob(pattern, glob_method):
def _check_glob(pattern, glob_method, **kwargs):
_assert_glob_results_match(
getattr(cloud_root, glob_method)(pattern),
getattr(local_root, glob_method)(pattern),
getattr(cloud_root, glob_method)(pattern, **kwargs),
getattr(local_root, glob_method)(pattern, **kwargs),
cloud_root,
local_root,
)
Expand Down Expand Up @@ -223,6 +224,21 @@ def _check_glob(pattern, glob_method):
dir_c_cloud.rglob("*/*"), dir_c_local.rglob("*/*"), dir_c_cloud, dir_c_local
)

# 3.12+ kwargs
if sys.version_info < (3, 12):
_check_glob("dir*/FILE*", "glob", case_sensitive=False)
_check_glob("dir*/file*", "glob", case_sensitive=True)
_check_glob("dir*/FILE*", "rglob", case_sensitive=False)
_check_glob("dir*/file*", "rglob", case_sensitive=True)

# test case insensitive for cloud; sensitive different pattern for local
_assert_glob_results_match(
dir_c_cloud.glob("FILE*", case_sensitive=False),
dir_c_local.glob("file*"),
dir_c_cloud,
dir_c_local,
)


def test_glob_buckets(rig):
# CloudPath("s3://").glob("*") results in error
Expand Down

0 comments on commit 921f84e

Please sign in to comment.