@@ -203,12 +203,9 @@ def test_schema_arg_dict_schema_error(self):
203203 list_schema = kde .list_schema (item_schema = schema_constants .FLOAT32 ).eval ()
204204 with self .assertRaisesRegex (
205205 ValueError ,
206- re .escape (
207- 'Python Dict can be converted to either Entity or Dict, got schema:'
208- ' DataItem(LIST[FLOAT32]'
209- ),
206+ re .escape ('schema mismatch: expected list/tuple' ),
210207 ):
211- fns .new ({'a' : [1 , 2 , 3 ], 'b' : [4 , 5 ]}, schema = list_schema )
208+ _ = fns .new ({'a' : [1 , 2 , 3 ], 'b' : [4 , 5 ]}, schema = list_schema )
212209
213210 def test_schema_arg_schema_with_fallback (self ):
214211 schema = kde .schema .new_schema (a = schema_constants .INT32 ).eval ()
@@ -514,12 +511,14 @@ def test_universal_converter_list_of_complex(self):
514511 )
515512
516513 def test_universal_converter_list_of_different_primitive_lists (self ):
517- with self .assertRaisesRegex (ValueError , 'cannot find a common schema' ):
518- fns .new ([[1 , 2 ], [3.14 ]])
519- fns .new (
514+ x = fns .new ([[1 , 2 ], [3.14 ]])
515+ y = fns .new (
520516 [[1 , 2 ], [3.14 ]],
521- schema = kde .list_schema (kde .list_schema (schema_constants .FLOAT32 )).eval ()
517+ schema = kde .list_schema (
518+ kde .list_schema (schema_constants .FLOAT32 )
519+ ).eval (),
522520 )
521+ testing .assert_equivalent (x , y )
523522
524523 def test_universal_converter_container_contains_multi_dim_data_slice (self ):
525524 with self .assertRaisesRegex (
@@ -596,12 +595,12 @@ def test_universal_converter_entity(self):
596595 with self .subTest ('item' ):
597596 entity = fns .new (a = 42 , b = 'abc' )
598597 new_entity = fns .new (entity )
599- testing .assert_not_equal (entity .get_bag (), new_entity .get_bag ())
598+ testing .assert_equal (entity .get_bag (), new_entity .get_bag ())
600599 testing .assert_equivalent (new_entity , entity )
601600 with self .subTest ('slice' ):
602601 entity = fns .new (a = ds ([1 , 2 ]), b = 'abc' )
603602 new_entity = fns .new (entity )
604- testing .assert_not_equal (entity .get_bag (), new_entity .get_bag ())
603+ testing .assert_equal (entity .get_bag (), new_entity .get_bag ())
605604 testing .assert_equivalent (new_entity , entity )
606605
607606 def test_universal_converter_adopt_bag_data (self ):
@@ -624,19 +623,29 @@ def test_universal_converter_with_cross_ref_schema_conflict(self):
624623 d2 = {'b' : 37 }
625624 d1 ['d' ] = d2
626625 d = {'d1' : d1 , 'd2' : d2 }
627- with self .assertRaisesRegex (ValueError , 'cannot find a common schema' ):
626+ with self .assertRaisesRegex (
627+ ValueError ,
628+ 'could not parse list of primitives / data items: object with'
629+ ' unsupported type: dict' ,
630+ ):
628631 fns .new (d )
629632
630633 def test_universal_converter_with_itemid (self ):
631634 itemid = kde .uuid_for_list ('new' ).eval ()
632635 res = fns .new ([{'a' : 42 , 'b' : 17 }, {'c' : 12 }], itemid = itemid )
633- child_itemid = kde .uuid_for_dict (
634- '__from_py_child__' , parent = itemid ,
635- list_item_index = ds ([0 , 1 ], schema_constants .INT64 )
636+ child_itemid = kde .uuid (
637+ '__from_py_child__' ,
638+ parent = itemid ,
639+ list_item_index = ds ([0 , 1 ], schema_constants .INT64 ),
640+ ).eval ()
641+ child_dict_item_id = kde .uuid_for_dict (
642+ '' ,
643+ base_itemid = child_itemid ,
636644 ).eval ()
645+
637646 testing .assert_equal (res .no_bag ().get_itemid (), itemid )
638647 testing .assert_dicts_keys_equal (res [:], ds ([['a' , 'b' ], ['c' ]]))
639- testing .assert_equal (res [:].no_bag ().get_itemid (), child_itemid )
648+ testing .assert_equal (res [:].no_bag ().get_itemid (), child_dict_item_id )
640649
641650 with self .assertRaisesRegex (
642651 ValueError , 'itemid argument to list creation, requires List ItemIds'
@@ -650,12 +659,18 @@ def test_universal_converter_with_itemid(self):
650659
651660 def test_universal_converter_recursive_object_error (self ):
652661 d = {'a' : 42 }
653- d ['self' ] = d
654- with self .assertRaisesRegex (ValueError , 'recursive .* cannot be converted' ):
662+ d ['a' ] = d
663+ with self .assertRaisesRegex (
664+ ValueError ,
665+ 'recursive Python object cannot be converted' ,
666+ ):
655667 fns .new (d )
656668 # Deeper recursion:
657669 d2 = {'a' : {'b' : d }}
658- with self .assertRaisesRegex (ValueError , 'recursive .* cannot be converted' ):
670+ with self .assertRaisesRegex (
671+ ValueError ,
672+ 'recursive Python object cannot be converted' ,
673+ ):
659674 fns .new (d2 )
660675 # Longer cycle:
661676 d = {'a' : 42 }
@@ -665,12 +680,17 @@ def test_universal_converter_recursive_object_error(self):
665680 level_1_d = d
666681 d = {'top' : d }
667682 bottom_d ['cycle' ] = level_1_d
668- with self .assertRaisesRegex (ValueError , 'recursive .* cannot be converted' ):
683+ with self .assertRaisesRegex (
684+ ValueError ,
685+ 'recursive Python object cannot be converted' ,
686+ ):
669687 fns .new (d2 )
670688 # Cycle in list:
671- l = [[1 , 2 ], 3 ]
689+ l = [[1 , 2 ], ( 3 ) ]
672690 l [0 ].append (l )
673- with self .assertRaisesRegex (ValueError , 'recursive .* cannot be converted' ):
691+ with self .assertRaisesRegex (
692+ ValueError , 'schema mismatch: expected list/tuple'
693+ ):
674694 fns .new (l )
675695
676696 def test_universal_converter_with_attrs (self ):
0 commit comments