(self)
| 177 | self.fail("Should raise ProgrammingError") |
| 178 | |
| 179 | def test_binary_prefix(self): |
| 180 | # verify prefix behaviour when enabled, disabled and for default (disabled) |
| 181 | for binary_prefix in (True, False, None): |
| 182 | kwargs = self.connect_kwargs.copy() |
| 183 | # needs to be set to can guarantee CHARSET response for normal strings |
| 184 | kwargs["charset"] = "utf8mb4" |
| 185 | if binary_prefix is not None: |
| 186 | kwargs["binary_prefix"] = binary_prefix |
| 187 | |
| 188 | with closing(connection_factory(**kwargs)) as conn: |
| 189 | with closing(conn.cursor()) as c: |
| 190 | c.execute("SELECT CHARSET(%s)", (MySQLdb.Binary(b"raw bytes"),)) |
| 191 | self.assertEqual( |
| 192 | c.fetchall()[0][0], "binary" if binary_prefix else "utf8mb4" |
| 193 | ) |
| 194 | # normal strings should not get prefix |
| 195 | c.execute("SELECT CHARSET(%s)", ("str",)) |
| 196 | self.assertEqual(c.fetchall()[0][0], "utf8mb4") |
| 197 | |
| 198 | |
| 199 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected