MCPcopy Create free account
hub / github.com/PyMySQL/PyMySQL / test_raise_mysql_exception

Function test_raise_mysql_exception

pymysql/tests/test_err.py:19–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17
18
19def test_raise_mysql_exception():
20 data = b"\xff\x15\x04#28000Access denied"
21 with pytest.raises(err.OperationalError) as cm:
22 err.raise_mysql_exception(data)
23 assert cm.type == err.OperationalError
24 assert cm.value.args == (1045, "Access denied")
25 assert cm.value.sqlstate == "28000"
26
27 data = b"\xff\x10\x04Too many connections"
28 with pytest.raises(err.OperationalError) as cm:
29 err.raise_mysql_exception(data)
30 assert cm.type == err.OperationalError
31 assert cm.value.args == (1040, "Too many connections")
32 assert cm.value.sqlstate is None
33
34
35def test_set_charset_deprecated():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected