Skip to content

Commit

Permalink
update test for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
MorvanZhou committed Nov 8, 2023
1 parent 644a146 commit 62a8aa1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/rethink/models/files/unzip.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import io
import os.path
import zipfile
from typing import Dict

Expand All @@ -13,11 +12,11 @@ def unzip_file(zip_bytes: bytes) -> Dict[str, bytes]:
_filepath = filepath.encode('cp437').decode('utf-8')
except UnicodeEncodeError:
_filepath = filepath
sp = _filepath.split(os.path.sep)
sp = _filepath.split("/")
if sp[0] in ["__MACOSX", ".DS_Store"]:
continue
if len(sp) > 1:
_filepath = os.path.sep.join(sp[1:])
_filepath = "/".join(sp[1:])
if _filepath.strip() == "" or _filepath.startswith("."):
continue
extracted_files[_filepath] = ref.read(filepath)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_models_files_unzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def test_unzip_folder(self):
with open("test.zip", "rb") as f:
extracted_files = unzip.unzip_file(f.read())
for filename, content in extracted_files.items():
self.assertEqual(self.orig_folder_data[os.path.join("a", filename)], content)
self.assertEqual(
self.orig_folder_data[os.path.join("a", filename)],
content,
msg=str(self.orig_folder_data))
os.remove("test.zip")

def test_unzip_files(self):
Expand Down

0 comments on commit 62a8aa1

Please sign in to comment.