From ed790738021a2966f4d4bec705fc0683ab269eb2 Mon Sep 17 00:00:00 2001 From: Adarsh Krishnan Date: Wed, 12 Mar 2014 10:20:48 +0200 Subject: [PATCH 1/3] Add separator to exception message in ScalarListType --- sqlalchemy_utils/types/scalar_list.py | 1 + tests/types/test_scalar_list.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sqlalchemy_utils/types/scalar_list.py b/sqlalchemy_utils/types/scalar_list.py index 41a2d80..4a79b59 100644 --- a/sqlalchemy_utils/types/scalar_list.py +++ b/sqlalchemy_utils/types/scalar_list.py @@ -67,6 +67,7 @@ class ScalarListType(types.TypeDecorator): "List values can't contain string '%s' (its being used as " "separator. If you wish for scalar list values to contain " "these strings, use a different separator string.)" + % self.separator ) return self.separator.join( map(six.text_type, value) diff --git a/tests/types/test_scalar_list.py b/tests/types/test_scalar_list.py index d928c7f..360b260 100644 --- a/tests/types/test_scalar_list.py +++ b/tests/types/test_scalar_list.py @@ -47,8 +47,14 @@ class TestScalarUnicodeList(TestCase): ) self.session.add(user) - with raises(sa.exc.StatementError): + with raises(sa.exc.StatementError) as db_err: self.session.commit() + print db_err.value.message + assert ( + "List values can't contain string ',' (its being used as " + "separator. If you wish for scalar list values to contain " + "these strings, use a different separator string.)" + ) in db_err.value.message def test_save_unicode_list(self): user = self.User( From 0a96cc54c749617866b8c25f9510c0422d890dca Mon Sep 17 00:00:00 2001 From: Adarsh Krishnan Date: Wed, 12 Mar 2014 12:27:04 +0200 Subject: [PATCH 2/3] Remove print statement from test_scalar_list.py --- tests/types/test_scalar_list.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/types/test_scalar_list.py b/tests/types/test_scalar_list.py index 360b260..abf0f8f 100644 --- a/tests/types/test_scalar_list.py +++ b/tests/types/test_scalar_list.py @@ -49,7 +49,6 @@ class TestScalarUnicodeList(TestCase): self.session.add(user) with raises(sa.exc.StatementError) as db_err: self.session.commit() - print db_err.value.message assert ( "List values can't contain string ',' (its being used as " "separator. If you wish for scalar list values to contain " From 8c55ebcd709e84a0e98723abd3a91c98f5e73a1a Mon Sep 17 00:00:00 2001 From: Adarsh Krishnan Date: Thu, 13 Mar 2014 01:25:28 +0200 Subject: [PATCH 3/3] Fix test_scalar_list.py for python3 --- tests/types/test_scalar_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/types/test_scalar_list.py b/tests/types/test_scalar_list.py index abf0f8f..89ce841 100644 --- a/tests/types/test_scalar_list.py +++ b/tests/types/test_scalar_list.py @@ -53,7 +53,7 @@ class TestScalarUnicodeList(TestCase): "List values can't contain string ',' (its being used as " "separator. If you wish for scalar list values to contain " "these strings, use a different separator string.)" - ) in db_err.value.message + ) in str(db_err.value) def test_save_unicode_list(self): user = self.User(