Skip to content

Commit

Permalink
(tests.archives) using binary.xxd to test PakFile .as_bytes() o…
Browse files Browse the repository at this point in the history
…utput
  • Loading branch information
snake-biscuits committed Aug 30, 2024
1 parent bdcb4ba commit 2b655a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion tests/archives/nexon/test_PakFile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from itertools import zip_longest

from bsp_tool.archives import nexon
from bsp_tool.utils import binary

import pytest

Expand Down Expand Up @@ -26,4 +29,9 @@
@pytest.mark.parametrize("raw_pakfile", pakfiles.values(), ids=pakfiles.keys())
def test_from_bytes(raw_pakfile: bytes):
pakfile = nexon.PakFile.from_bytes(raw_pakfile)
assert pakfile.as_bytes() == raw_pakfile
pakfile_bytes = pakfile.as_bytes()
# compare
original = binary.xxd_bytes(raw_pakfile)
remake = binary.xxd_bytes(pakfile_bytes)
for expected, actual in zip_longest(original, remake, fillvalue=""):
assert expected == actual
10 changes: 9 additions & 1 deletion tests/archives/pkware/test_Zip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from itertools import zip_longest

from bsp_tool.archives import pkware
from bsp_tool.utils import binary

import pytest

Expand Down Expand Up @@ -50,7 +53,12 @@ def test_new():
@pytest.mark.parametrize("raw_zip", zips.values(), ids=zips.keys())
def test_bytes(raw_zip: bytes):
zip_ = pkware.Zip.from_bytes(raw_zip)
assert zip_.as_bytes() == raw_zip
zip_bytes = zip_.as_bytes()
# compare
original = binary.xxd_bytes(raw_zip)
remake = binary.xxd_bytes(zip_bytes)
for expected, actual in zip_longest(original, remake, fillvalue=""):
assert expected == actual


def test_save_changes():
Expand Down

0 comments on commit 2b655a1

Please sign in to comment.