Skip to content

Commit 3eadc74

Browse files
committed
fix: fix #4
Remove the dependecy on gunzip and now rely on magic number entirely.
1 parent 84dc7e7 commit 3eadc74

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

grading_lib/common.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,14 @@ def tearDown(self) -> None:
178178
f"[info]: The temporary directory at '{self.temporary_dir_path}' is not deleted since the DEBUG is set to True."
179179
)
180180

181-
def assertArchiveFileIsGzip(self, path: Path) -> None:
182-
cmd_result = run_executable(["gunzip", "-t", str(path)])
183-
self.assertTrue(
184-
"not in gzip format" not in cmd_result.output,
185-
msg="Hint: Did you forget to use '-z' flag when creating the archive?",
186-
)
187-
self.assertCommandSuccessful(
188-
cmd_result,
189-
)
181+
def assertArchiveFileIsGzip(self, path: str | Path) -> None:
182+
if isinstance(path, str):
183+
path = Path(path)
184+
with open(path, "rb") as f:
185+
self.assertTrue(
186+
f.read(2) == b"\x1f\x8b",
187+
msg="Hint: Did you forget to use '-z' flag when creating the archive?",
188+
)
190189

191190
def assertFileExists(
192191
self, path: Path, msg_template: str = FILE_NOT_EXIST_TEXT_TEMPLATE

0 commit comments

Comments
 (0)