File: test_err.py

package info (click to toggle)
python-pymysql 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 848 kB
  • sloc: python: 6,396; makefile: 134; sh: 44; sql: 10
file content (16 lines) | stat: -rw-r--r-- 549 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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")