Skip to content

Commit 58eae49

Browse files
committed
Add test to verify correct handling of Unicode.
1 parent 49f7bd2 commit 58eae49

File tree

1 file changed

+32
-0
lines changed
  • instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/utils

1 file changed

+32
-0
lines changed

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/utils/test_dict_util.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,38 @@ def test_flatten_with_mixed_structures():
206206
"foo.pydantic.int_value": 123,
207207
}
208208

209+
def test_converts_tuple_with_json_fallback():
210+
input_dict = {
211+
"foo": ("abc", 123),
212+
}
213+
output = dict_util.flatten_dict(input_dict)
214+
assert output == {
215+
"foo.length": 2,
216+
"foo[0]": "abc",
217+
"foo[1]": 123,
218+
}
219+
220+
def test_converts_tuple_with_json_fallback():
221+
input_dict = {
222+
"foo": ("abc", 123),
223+
}
224+
output = dict_util.flatten_dict(input_dict)
225+
assert output == {
226+
"foo.length": 2,
227+
"foo[0]": "abc",
228+
"foo[1]": 123,
229+
}
230+
231+
def test_json_conversion_handles_unicode():
232+
input_dict = {
233+
"foo": ("❤️", 123),
234+
}
235+
output = dict_util.flatten_dict(input_dict)
236+
assert output == {
237+
"foo.length": 2,
238+
"foo[0]": "❤️",
239+
"foo[1]": 123,
240+
}
209241

210242
def test_flatten_with_complex_object_not_json_serializable():
211243
result = dict_util.flatten_dict(

0 commit comments

Comments
 (0)