def test_invalid_string_is_found_in_dict_key(self):
     objects = (
         {
             "naïve fiancé 👰🏻": "first",
             "hello\udce2\udce2": "second"
         },
         {
             "first": {
                 "hello\udce2\udce2": "subvalue"
             },
             "🤷🏻‍♂️": "second"
         },
         [{
             "hello\udce2\udce2": "first"
         }],
         {
             "deep": [
                 "deeper", {
                     "deepest": [
                         "Mariana trench", {
                             "hello\udce2\udce2": "Earth core"
                         }
                     ]
                 }
             ]
         },
     )
     for obj in objects:
         with self.subTest(object=obj):
             with self.assertRaises(UnicodeEncodeError):
                 _validate_json_object_for_utf8(obj)
 def test_invalid_string_is_found_in_list_item(self):
     objects = (
         ["naïve fiancé 👰🏻", "hello\udce2\udce2"],
         {
             "first": ["hello\udce2\udce2"],
             "second": "🤷🏻‍♂️"
         },
         ["first", ["hello\udce2\udce2"]],
         [
             "deep", {
                 "deeper": [
                     "deepest", {
                         "Mariana trench":
                         ["Earth core", "hello\udce2\udce2"]
                     }
                 ]
             }
         ],
     )
     for obj in objects:
         with self.subTest(object=obj):
             with self.assertRaises(UnicodeEncodeError):
                 _validate_json_object_for_utf8(obj)
 def test_other_values_are_ignored(self):
     values = (1.23, 0, 123, -123, True, False, None)
     for value in values:
         with self.subTest(value=value):
             _validate_json_object_for_utf8(value)
             self.assertTrue(True)
 def test_lists_are_traversed(self, mock):
     _validate_json_object_for_utf8(["first", "second"])
     mock.assert_has_calls((call("first"), call("second")), any_order=True)
 def test_dicts_are_traversed(self, mock):
     _validate_json_object_for_utf8({"first": "item", "second": "value"})
     mock.assert_has_calls(
         (call("first"), call("item"), call("second"), call("value")),
         any_order=True)
 def test_invalid_string_raises_exception(self):
     with self.assertRaises(UnicodeEncodeError):
         _validate_json_object_for_utf8("hello\udce2\udce2")
 def test_valid_string_is_ok(self):
     _validate_json_object_for_utf8("naïve fiancé 👰🏻")
     self.assertTrue(True)