-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support error packet without sqlstate (#1160)
Fix #1156
- Loading branch information
Showing
4 changed files
with
22 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters