@@ -4350,11 +4350,39 @@ def test_is_copy(self):
4350
4350
assert schema is not other
4351
4351
4352
4352
def test_name_collision (self ):
4353
+ schema = MetadataSchema .permissive_json ().schema
4354
+ schema = tsinfer .add_to_schema (
4355
+ schema , "name" , definition = {"type" : "number" , "description" : "something" }
4356
+ )
4357
+ with pytest .raises (ValueError ):
4358
+ tsinfer .add_to_schema (
4359
+ schema , "name" , definition = {"type" : "number" , "description" : "alt" }
4360
+ )
4361
+
4362
+ def test_name_collision_no_definition (self ):
4353
4363
schema = MetadataSchema .permissive_json ().schema
4354
4364
schema = tsinfer .add_to_schema (schema , "name" )
4355
4365
with pytest .raises (ValueError ):
4356
4366
tsinfer .add_to_schema (schema , "name" )
4357
4367
4368
+ def test_name_collision_same_description (self , caplog ):
4369
+ schema = MetadataSchema .permissive_json ().schema
4370
+ with caplog .at_level (logging .WARNING ):
4371
+ schema1 = tsinfer .add_to_schema (
4372
+ schema ,
4373
+ "name" ,
4374
+ definition = {"description" : "a unique description" , "type" : "number" },
4375
+ )
4376
+ assert caplog .text == ""
4377
+ with caplog .at_level (logging .WARNING ):
4378
+ schema2 = tsinfer .add_to_schema (
4379
+ schema1 ,
4380
+ "name" ,
4381
+ definition = {"type" : "number" , "description" : "a unique description" },
4382
+ )
4383
+ assert "already in schema" in caplog .text
4384
+ assert schema1 == schema2
4385
+
4358
4386
def test_defaults (self ):
4359
4387
schema = MetadataSchema .permissive_json ().schema
4360
4388
schema = tsinfer .add_to_schema (schema , "name" )
0 commit comments