@@ -70,6 +70,51 @@ def test___python_panel_collection___to_any___valid_paneltype_value(
7070 assert unpack_dest .values == expected_value
7171
7272
73+ # ========================================================
74+ # _get_best_matching_type() tests
75+ # ========================================================
76+ @pytest .mark .parametrize (
77+ "python_object, expected_type_string" ,
78+ [
79+ (False , "bool" ),
80+ (b"mystr" , "bytes" ),
81+ (456.2 , "float" ),
82+ (123 , "int" ),
83+ ("mystr" , "str" ),
84+ ([False , False ], "Collection.bool" ),
85+ ([b"mystr" , b"mystr" ], "Collection.bytes" ),
86+ ([456.2 , 1.0 ], "Collection.float" ),
87+ ([123 , 456 ], "Collection.int" ),
88+ (["mystr" , "mystr" ], "Collection.str" ),
89+ ((False , False ), "Collection.bool" ),
90+ ((b"mystr" , b"mystr" ), "Collection.bytes" ),
91+ ((456.2 , 1.0 ), "Collection.float" ),
92+ ((123 , 456 ), "Collection.int" ),
93+ (("mystr" , "mystr" ), "Collection.str" ),
94+ ((False , False ), "Collection.bool" ),
95+ ((b"mystr" , b"mystr" ), "Collection.bytes" ),
96+ ((456.2 , 1.0 ), "Collection.float" ),
97+ ((123 , 456 ), "Collection.int" ),
98+ (("mystr" , "mystr" ), "Collection.str" ),
99+ (set ([False , True ]), "Collection.bool" ),
100+ (set ([b"mystr" , b"mystr2" ]), "Collection.bytes" ),
101+ (set ([456.2 , 1.0 ]), "Collection.float" ),
102+ (set ([123 , 456 ]), "Collection.int" ),
103+ (set (["mystr" , "mystr2" ]), "Collection.str" ),
104+ (frozenset ([False , True ]), "Collection.bool" ),
105+ (frozenset ([b"mystr" , b"mystr2" ]), "Collection.bytes" ),
106+ (frozenset ([456.2 , 1.0 ]), "Collection.float" ),
107+ (frozenset ([123 , 456 ]), "Collection.int" ),
108+ (frozenset (["mystr" , "mystr2" ]), "Collection.str" ),
109+ ],
110+ )
111+ def test___various_python_objects___get_best_matching_type___returns_correct_type_string (
112+ python_object : object , expected_type_string : str
113+ ) -> None :
114+ type_string = nipanel ._convert ._get_best_matching_type (python_object )
115+ assert type_string == expected_type_string
116+
117+
73118# ========================================================
74119# Protobuf to Python
75120# ========================================================
0 commit comments