tests: skip the fmt=5 codec tests where numpy is absent

CI keeps the runtime path dependency-free, so the Python test job runs
without numpy and the new codec tests errored on import. Guard the import
and skip the class instead — verified both ways: 6/6 run where numpy is
present, 6/6 skip cleanly where it is not.
This commit is contained in:
ZacharyZcR
2026-07-21 01:34:26 +08:00
parent e48346162a
commit 7291fd19ac
+11 -3
View File
@@ -9,10 +9,17 @@ import os
import sys
import unittest
import numpy as np
# The runtime path is dependency-free by design and CI keeps it that way, so the
# offline-tooling tests skip rather than fail where numpy is absent.
np = None
P = None
try:
import numpy as np
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "tools"))
import iq3_pack as P # noqa: E402
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "tools"))
import iq3_pack as P
except ImportError: # pragma: no cover - exercised only on dependency-free CI
pass
def ref_decode(packed, K):
@@ -43,6 +50,7 @@ def ref_decode(packed, K):
return out
@unittest.skipIf(P is None, "numpy not available (offline-tooling test)")
class TestIq3Pack(unittest.TestCase):
def setUp(self):
np.random.seed(4242)