Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add test
  • Loading branch information
methane committed Feb 2, 2024
commit 4cccf50e5b65490ff44682b6ac8d8af9ccb83b1e
22 changes: 12 additions & 10 deletions pymysql/tests/test_err.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import unittest

import pytest
from pymysql import err


__all__ = ["TestRaiseException"]

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")

class TestRaiseException(unittest.TestCase):
def test_raise_mysql_exception(self):
data = b"\xff\x15\x04#28000Access denied"
with self.assertRaises(err.OperationalError) as cm:
err.raise_mysql_exception(data)
self.assertEqual(cm.exception.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")