From 0ef479abda2fe72a9a365e1059761b54e5a0639a Mon Sep 17 00:00:00 2001 From: Deeptanshu Sekhri Date: Thu, 24 Jul 2025 15:07:39 +0100 Subject: [PATCH 1/2] test(cli): skip permission based tests under root & Windows Permission-based tests expecting "Permission Denied" errors are invalid when run as root or on Windows. Adding mechanism to skip those tests: - Guard in skip_if_root marker to only apply on POSIX. - New skip_on_windows marker to skip these tests on Windows. Signed-off-by: Deeptanshu Sekhri --- tests/test_cli.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 5c85c21..8b2ca2d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -322,11 +322,18 @@ def test_help_flag_writes_usage(cli_path: str, out_dir: Path) -> None: # Skip tests that depend on filesystem permission errors when running as root, # since root privileges override normal file permission checks. skip_if_root = pytest.mark.skipif( - os.geteuid() == 0, reason="Skipping tests requiring permission errors under root" + os.name == "posix" and os.geteuid() == 0, + reason="Skipping tests requiring permission errors under root", +) + +# Skip test on Windows ex: POSIX style directory permissions test +skip_on_windows = pytest.mark.skipif( + sys.platform == "win32", reason="Skipping permission based tests on Windows" ) @skip_if_root +@skip_on_windows @pytest.mark.cli def test_output_to_unwritable_directory( cli_path: str, mobilenet_tflite: Path, out_dir: Path -- GitLab From 2bf131b2fdfec6ff37c16a07f65b77367c5b3cc7 Mon Sep 17 00:00:00 2001 From: Deeptanshu Sekhri Date: Fri, 25 Jul 2025 08:49:21 +0100 Subject: [PATCH 2/2] fix(test): enforce UTF-8 encoding when opening JSON manifest file On Windows, `open()` without an explicit `encoding` uses ANSI, which triggers `UnicodeDecodeError. Specifying `encoding="utf-8"` to ensure consistency across platforms. Signed-off-by: Deeptanshu Sekhri --- tests/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 8b2ca2d..9af48c8 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -61,7 +61,7 @@ JSON_PATH = Path(__file__).parent / "test_cli.hjson" # external test definition # ─────────────────────────────────────────────────────────────────────────────── # Load & validate test cases from JSON # ─────────────────────────────────────────────────────────────────────────────── -with JSON_PATH.open() as f: +with open(JSON_PATH, encoding="utf-8") as f: CLI_TEST_CASES: List[Dict[str, Any]] = hjson.load(f) logger.info("Loaded %d test cases from %s", len(CLI_TEST_CASES), JSON_PATH) -- GitLab