From 85b75ae194a4e434b8d8e61ad50375d5e1dd426b Mon Sep 17 00:00:00 2001 From: sneakocom <192013763+sneakocom@users.noreply.github.com> Date: Fri, 18 Sep 2026 01:33:04 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Add=20test=20for=20invalid=20JSO?= =?UTF-8?q?N=20load=20error=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- tests/test_validate_program.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_validate_program.py b/tests/test_validate_program.py index d408ce3..44a16a8 100644 --- a/tests/test_validate_program.py +++ b/tests/test_validate_program.py @@ -2,6 +2,7 @@ import copy import sys +import tempfile import unittest from pathlib import Path @@ -26,6 +27,23 @@ def setUp(self) -> None: def errors_for(self, registry=None, experiments=None): return validate(registry or self.registry, experiments or self.experiments) + + def test_load_json_raises_value_error_on_non_object(self): + with tempfile.TemporaryDirectory() as tmpdir: + path = Path(tmpdir) / "test.json" + + # Test with list + path.write_text('["array"]') + with self.assertRaises(ValueError) as context: + load_json(path) + self.assertIn("top-level value must be an object", str(context.exception)) + + # Test with string + path.write_text('"string"') + with self.assertRaises(ValueError) as context: + load_json(path) + self.assertIn("top-level value must be an object", str(context.exception)) + def test_authoritative_registries_are_valid(self): self.assertEqual(self.errors_for(), [])