@@ -232,6 +232,19 @@ def test_rejects_non_string_row_keys_with_context(self):
232232 with self .assertRaisesRegex (ValueError , r"row 0.*field.*1.*string" ):
233233 build_inventory ([row ])
234234
235+ def test_rejects_non_utf8_top_level_field_names_with_context (self ):
236+ row = accepted_row ()
237+ row ["\ud800 " ] = "invalid key"
238+
239+ with self .assertRaises (ValueError ) as raised :
240+ build_inventory ([row ])
241+
242+ message = str (raised .exception )
243+ self .assertIn ("row 0" , message )
244+ self .assertIn ("field name" , message )
245+ self .assertIn ("\\ ud800" , message )
246+ self .assertIn ("UTF-8" , message )
247+
235248 def test_rejects_non_finite_and_non_utf8_metadata (self ):
236249 invalid_metadata = (
237250 (float ("nan" ), "JSON" ),
@@ -467,6 +480,50 @@ def test_rejects_same_path_aliases_before_reading_or_writing(self):
467480 self .assertEqual (input_path .read_text (encoding = "utf-8" ), "not JSON\n " )
468481 self .assertFalse (shared_output_path .exists ())
469482
483+ def test_rejects_nonexistent_output_names_differing_only_by_case (self ):
484+ with tempfile .TemporaryDirectory () as directory :
485+ directory = Path (directory )
486+ input_path = directory / "raw.jsonl"
487+ inventory_path = directory / "Inventory.jsonl"
488+ diagnostics_path = directory / "inventory.jsonl"
489+ input_path .write_text ("" , encoding = "utf-8" )
490+
491+ result = self .run_cli (
492+ "--input" ,
493+ input_path ,
494+ "--inventory" ,
495+ inventory_path ,
496+ "--diagnostics" ,
497+ diagnostics_path ,
498+ )
499+
500+ self .assertNotEqual (result .returncode , 0 )
501+ self .assertIn ("distinct files" , result .stderr )
502+ self .assertFalse (inventory_path .exists ())
503+ self .assertFalse (diagnostics_path .exists ())
504+
505+ def test_rejects_nonexistent_output_names_with_equivalent_unicode (self ):
506+ with tempfile .TemporaryDirectory () as directory :
507+ directory = Path (directory )
508+ input_path = directory / "raw.jsonl"
509+ inventory_path = directory / "caf\u00e9 .jsonl"
510+ diagnostics_path = directory / "cafe\u0301 .jsonl"
511+ input_path .write_text ("" , encoding = "utf-8" )
512+
513+ result = self .run_cli (
514+ "--input" ,
515+ input_path ,
516+ "--inventory" ,
517+ inventory_path ,
518+ "--diagnostics" ,
519+ diagnostics_path ,
520+ )
521+
522+ self .assertNotEqual (result .returncode , 0 )
523+ self .assertIn ("distinct files" , result .stderr )
524+ self .assertFalse (inventory_path .exists ())
525+ self .assertFalse (diagnostics_path .exists ())
526+
470527 @unittest .skipUnless (hasattr (os , "symlink" ), "symlinks are unavailable" )
471528 def test_rejects_existing_symlink_path_aliases (self ):
472529 with tempfile .TemporaryDirectory () as directory :
0 commit comments