File size: 549 Bytes
065fee7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import pytest
from pymysql import err


def test_raise_mysql_exception():
    data = b"\xff\x15\x04#28000Access denied"
    with pytest.raises(err.OperationalError) as cm:
        err.raise_mysql_exception(data)
    assert cm.type == err.OperationalError
    assert cm.value.args == (1045, "Access denied")

    data = b"\xff\x10\x04Too many connections"
    with pytest.raises(err.OperationalError) as cm:
        err.raise_mysql_exception(data)
    assert cm.type == err.OperationalError
    assert cm.value.args == (1040, "Too many connections")