diff options
Diffstat (limited to 'test/engine/test_logging.py')
| -rw-r--r-- | test/engine/test_logging.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/test/engine/test_logging.py b/test/engine/test_logging.py index efdee8aef..51ebc5250 100644 --- a/test/engine/test_logging.py +++ b/test/engine/test_logging.py @@ -1,4 +1,4 @@ -from sqlalchemy.testing import eq_, assert_raises_message +from sqlalchemy.testing import eq_, assert_raises_message, eq_regex from sqlalchemy import select import sqlalchemy as tsa from sqlalchemy.testing import engines @@ -8,6 +8,7 @@ from sqlalchemy.testing import mock from sqlalchemy.testing.util import lazy_gc from sqlalchemy import util + class LogParamsTest(fixtures.TestBase): __only_on__ = 'sqlite' __requires__ = 'ad_hoc_engines', @@ -106,6 +107,31 @@ class LogParamsTest(fixtures.TestBase): ) ) + def test_exception_format_dict_param(self): + exception = tsa.exc.IntegrityError("foo", {"x": "y"}, None) + eq_regex( + str(exception), + r"\(.*.NoneType\) None \[SQL: 'foo'\] \[parameters: {'x': 'y'}\]" + ) + + def test_exception_format_unexpected_parameter(self): + # test that if the parameters aren't any known type, we just + # run through repr() + exception = tsa.exc.IntegrityError("foo", "bar", "bat") + eq_regex( + str(exception), + r"\(.*.str\) bat \[SQL: 'foo'\] \[parameters: 'bar'\]" + ) + + def test_exception_format_unexpected_member_parameter(self): + # test that if the parameters aren't any known type, we just + # run through repr() + exception = tsa.exc.IntegrityError("foo", ["bar", "bat"], "hoho") + eq_regex( + str(exception), + r"\(.*.str\) hoho \[SQL: 'foo'\] \[parameters: \['bar', 'bat'\]\]" + ) + def test_result_large_param(self): import random largeparam = ''.join(chr(random.randint(52, 85)) for i in range(5000)) |
