summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVik <vmuriart@gmail.com>2016-09-12 00:14:01 -0700
committerGitHub <noreply@github.com>2016-09-12 00:14:01 -0700
commit47fef6b7cb1fa8edd83dd31eb73aaf3c9afff086 (patch)
treecda75d04543a02e20bf04ab01c8dfc5e670a269d /tests
parent791a3312a247670cdeed61e52e8ca449dbb27afa (diff)
parent843499915e91e0ee324a0407c78ac6f570806370 (diff)
downloadsqlparse-47fef6b7cb1fa8edd83dd31eb73aaf3c9afff086.tar.gz
Merge pull request #287 from phdru/master
Convert string literals to unicode using u() for Py27
Diffstat (limited to 'tests')
-rw-r--r--tests/test_parse.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/test_parse.py b/tests/test_parse.py
index 8dd1150..0632889 100644
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -6,7 +6,7 @@ import pytest
import sqlparse
from sqlparse import sql, tokens as T
-from sqlparse.compat import StringIO
+from sqlparse.compat import StringIO, text_type
def test_parse_tokenize():
@@ -403,3 +403,21 @@ def test_dbldollar_as_literal(sql, is_literal):
else:
for token in p.tokens:
assert token.ttype != T.Literal
+
+
+def test_non_ascii():
+ _test_non_ascii = u"insert into test (id, name) values (1, 'ั‚ะตัั‚');"
+
+ s = _test_non_ascii
+ stmts = sqlparse.parse(s)
+ assert len(stmts) == 1
+ statement = stmts[0]
+ assert text_type(statement) == s
+ assert statement._pprint_tree() is None
+
+ s = _test_non_ascii.encode('utf-8')
+ stmts = sqlparse.parse(s, 'utf-8')
+ assert len(stmts) == 1
+ statement = stmts[0]
+ assert text_type(statement) == _test_non_ascii
+ assert statement._pprint_tree() is None