Skip to content

Commit

Permalink
dev(narugo): fix upload issue on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
narugo1992 committed Dec 24, 2023
1 parent 5afd666 commit 05571d7
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions test/operate/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def test_upload_file_to_file(self, hf_repo, hf_fs):
file_in_repo='kkk/raw_remote.tar'
)

assert hf_fs.read_bytes(f'datasets/{hf_repo}/kkk/raw_remote.tar') == \
pathlib.Path(get_testfile('raw.tar')).read_bytes()
assert hf_fs.read_text(f'datasets/{hf_repo}/kkk/raw_remote.tar') == \
pathlib.Path(get_testfile('raw.tar')).read_text()

def test_upload_directory_as_archive(self, hf_repo, hf_fs, raw_dir, check_unpack_dir):
upload_directory_as_archive(
Expand All @@ -66,12 +66,12 @@ def test_upload_directory_as_directory(self, hf_repo_with_files, hf_fs, raw_dir)
path_in_repo='.',
)

assert hf_fs.read_bytes(f'datasets/{hf_repo_with_files}/1.txt') == \
pathlib.Path(get_testfile(raw_dir, '1.txt')).read_bytes()
assert hf_fs.read_bytes(f'datasets/{hf_repo_with_files}/README.md') == \
pathlib.Path(get_testfile(raw_dir, 'README.md')).read_bytes()
assert hf_fs.read_bytes(f'datasets/{hf_repo_with_files}/subdir/script.py') == \
pathlib.Path(get_testfile(raw_dir, 'subdir', 'script.py')).read_bytes()
assert hf_fs.read_text(f'datasets/{hf_repo_with_files}/1.txt').splitlines(keepends=False) == \
pathlib.Path(get_testfile(raw_dir, '1.txt')).read_text().splitlines(keepends=False)
assert hf_fs.read_text(f'datasets/{hf_repo_with_files}/README.md').splitlines(keepends=False) == \
pathlib.Path(get_testfile(raw_dir, 'README.md')).read_text().splitlines(keepends=False)
assert hf_fs.read_text(f'datasets/{hf_repo_with_files}/subdir/script.py').splitlines(keepends=False) == \
pathlib.Path(get_testfile(raw_dir, 'subdir', 'script.py')).read_text().splitlines(keepends=False)
assert hf_fs.exists(f'datasets/{hf_repo_with_files}/.gitattributes')
assert hf_fs.exists(f'datasets/{hf_repo_with_files}/bullshit.txt')

Expand All @@ -83,12 +83,12 @@ def test_upload_directory_as_directory_clear(self, hf_repo_with_files, hf_fs, ra
clear=True,
)

assert hf_fs.read_bytes(f'datasets/{hf_repo_with_files}/1.txt') == \
pathlib.Path(get_testfile(raw_dir, '1.txt')).read_bytes()
assert hf_fs.read_bytes(f'datasets/{hf_repo_with_files}/README.md') == \
pathlib.Path(get_testfile(raw_dir, 'README.md')).read_bytes()
assert hf_fs.read_bytes(f'datasets/{hf_repo_with_files}/subdir/script.py') == \
pathlib.Path(get_testfile(raw_dir, 'subdir', 'script.py')).read_bytes()
assert hf_fs.read_text(f'datasets/{hf_repo_with_files}/1.txt').splitlines(keepends=False) == \
pathlib.Path(get_testfile(raw_dir, '1.txt')).read_text().splitlines(keepends=False)
assert hf_fs.read_text(f'datasets/{hf_repo_with_files}/README.md').splitlines(keepends=False) == \
pathlib.Path(get_testfile(raw_dir, 'README.md')).read_text().splitlines(keepends=False)
assert hf_fs.read_text(f'datasets/{hf_repo_with_files}/subdir/script.py').splitlines(keepends=False) == \
pathlib.Path(get_testfile(raw_dir, 'subdir', 'script.py')).read_text().splitlines(keepends=False)
assert hf_fs.exists(f'datasets/{hf_repo_with_files}/.gitattributes')
assert not hf_fs.exists(f'datasets/{hf_repo_with_files}/bullshit.txt')

Expand All @@ -99,9 +99,9 @@ def test_upload_directory_as_directory_in_subdir(self, hf_repo_with_files, hf_fs
path_in_repo='ttt',
)

assert hf_fs.read_bytes(f'datasets/{hf_repo_with_files}/ttt/1.txt') == \
pathlib.Path(get_testfile(raw_dir, '1.txt')).read_bytes()
assert hf_fs.read_bytes(f'datasets/{hf_repo_with_files}/ttt/README.md') == \
pathlib.Path(get_testfile(raw_dir, 'README.md')).read_bytes()
assert hf_fs.read_bytes(f'datasets/{hf_repo_with_files}/ttt/subdir/script.py') == \
pathlib.Path(get_testfile(raw_dir, 'subdir', 'script.py')).read_bytes()
assert hf_fs.read_text(f'datasets/{hf_repo_with_files}/ttt/1.txt').splitlines(keepends=False) == \
pathlib.Path(get_testfile(raw_dir, '1.txt')).read_text().splitlines(keepends=False)
assert hf_fs.read_text(f'datasets/{hf_repo_with_files}/ttt/README.md').splitlines(keepends=False) == \
pathlib.Path(get_testfile(raw_dir, 'README.md')).read_text().splitlines(keepends=False)
assert hf_fs.read_text(f'datasets/{hf_repo_with_files}/ttt/subdir/script.py').splitlines(keepends=False) == \
pathlib.Path(get_testfile(raw_dir, 'subdir', 'script.py')).read_text().splitlines(keepends=False)

0 comments on commit 05571d7

Please sign in to comment.