mirror of
https://github.com/botlabsDev/npkpy.git
synced 2025-12-10 06:54:37 +01:00
add 'NPKMagicBytesError' for #1
This commit is contained in:
parent
d1513c28b7
commit
d98b456c7d
3 changed files with 8 additions and 4 deletions
|
|
@ -66,5 +66,9 @@ class NPKIdError(BaseException):
|
|||
pass
|
||||
|
||||
|
||||
class NPKMagicBytesError(BaseException):
|
||||
pass
|
||||
|
||||
|
||||
class NPKError(BaseException):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import struct
|
||||
from pathlib import Path
|
||||
|
||||
from npkpy.common import NPKError, NPKIdError
|
||||
from npkpy.common import NPKError, NPKIdError, NPKMagicBytesError
|
||||
from npkpy.npk.npk_constants import CNT_HANDLER
|
||||
from npkpy.npk.cnt_basic import BYTES_LEN_CNT_ID, BYTES_LEN_CNT_PAYLOAD_LEN
|
||||
from npkpy.npk.npk_file_basic import FileBasic
|
||||
|
|
@ -99,4 +99,4 @@ class Npk(FileBasic):
|
|||
|
||||
def _check_magic_bytes(self, error_msg):
|
||||
if not self.pck_magic_bytes == MAGIC_BYTES:
|
||||
raise NPKError(error_msg)
|
||||
raise NPKMagicBytesError(error_msg)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import tempfile
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from npkpy.common import NPKError, NPKIdError
|
||||
from npkpy.common import NPKError, NPKIdError, NPKMagicBytesError
|
||||
from npkpy.npk.npk import Npk
|
||||
from npkpy.npk.pck_header import PckHeader
|
||||
from tests.constants import DummyHeaderCnt, MAGIC_BYTES, get_dummy_npk_binary
|
||||
|
|
@ -18,7 +18,7 @@ class Test_npkClass(unittest.TestCase):
|
|||
def test_fileIsNoNpkFile(self):
|
||||
self.npkFile.write_bytes(b"NoMagicBytesAtHeadOfFile")
|
||||
|
||||
with self.assertRaises(NPKError) as e:
|
||||
with self.assertRaises(NPKMagicBytesError) as e:
|
||||
_ = Npk(self.npkFile).pck_magic_bytes
|
||||
self.assertEqual(e.exception.args[0], "Magic bytes not found in Npk file")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue