MCPcopy Create free account
hub / github.com/PyMySQL/mysqlclient / test_binary_prefix

Method test_binary_prefix

tests/test_MySQLdb_capabilities.py:179–196  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
199if __name__ == "__main__":

Callers

nothing calls this directly

Calls 4

connection_factoryFunction · 0.90
cursorMethod · 0.80
executeMethod · 0.80
fetchallMethod · 0.45

Tested by

no test coverage detected