(self)
| 123 | self.assertRaisesRegex(TypeError, msg, self.loads, value) |
| 124 | |
| 125 | def test_string_with_utf8_bom(self): |
| 126 | # see #18958 |
| 127 | bom_json = "[1,2,3]".encode('utf-8-sig').decode('utf-8') |
| 128 | with self.assertRaises(self.JSONDecodeError) as cm: |
| 129 | self.loads(bom_json) |
| 130 | self.assertIn('BOM', str(cm.exception)) |
| 131 | with self.assertRaises(self.JSONDecodeError) as cm: |
| 132 | self.json.load(StringIO(bom_json)) |
| 133 | self.assertIn('BOM', str(cm.exception)) |
| 134 | # make sure that the BOM is not detected in the middle of a string |
| 135 | bom = ''.encode('utf-8-sig').decode('utf-8') |
| 136 | bom_in_str = f'"{bom}"' |
| 137 | self.assertEqual(self.loads(bom_in_str), '\ufeff') |
| 138 | self.assertEqual(self.json.load(StringIO(bom_in_str)), '\ufeff') |
| 139 | |
| 140 | def test_negative_index(self): |
| 141 | d = self.json.JSONDecoder() |
nothing calls this directly
no test coverage detected