[PATCH v2] fixup! test: py: add TLV integration tests

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Oct 15 02:26:01 PDT 2025


test: py: tlv: skip tests if crcmod is missing

We document nowhere that crcmod is a required dependency for the test
suite. Skip the tests requiring it if it's not installed.

In the future, it's probably worthwhile to add some requirements.txt or
similar that uv could use to set up a python environment with all the
dependencies?

Cc: Jonas Rebmann <jre at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
v1 -> v2:
  - do not touch the generator and do the skipping in the test itself to
    allow for easier backporting (Jonas)
---
 test/py/test_tlv.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/test/py/test_tlv.py b/test/py/test_tlv.py
index 963f3749b33b..c1bb9a17b4a8 100644
--- a/test/py/test_tlv.py
+++ b/test/py/test_tlv.py
@@ -1,14 +1,17 @@
+import sys
 import os
 import re
 import subprocess
 from pathlib import Path
-from crcmod.predefined import mkPredefinedCrcFun
 from .helper import skip_disabled
-
-_crc32_mpeg = mkPredefinedCrcFun("crc-32-mpeg")
-
 import pytest
 
+try:
+    from crcmod.predefined import mkPredefinedCrcFun
+    _crc32_mpeg = mkPredefinedCrcFun("crc-32-mpeg")
+except ModuleNotFoundError:
+    _crc32_mpeg = None
+
 
 class _TLV_Testdata:
     def generator(self, args, check=True):
@@ -29,6 +32,9 @@ class _TLV_Testdata:
 
 @pytest.fixture(scope="module")
 def tlv_testdata(testfs):
+    if _crc32_mpeg is None:
+        pytest.skip("missing crcmod dependency")
+
     t = _TLV_Testdata(testfs)
     t.generator(["--input-data", str(t.data), str(t.schema), str(t.unsigned_bin)])
     assert t.unsigned_bin.exists(), "unsigned TLV not created"
-- 
2.47.3




More information about the barebox mailing list