diff options
| author | Vik <vmuriart@gmail.com> | 2016-09-12 00:14:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-12 00:14:01 -0700 |
| commit | 47fef6b7cb1fa8edd83dd31eb73aaf3c9afff086 (patch) | |
| tree | cda75d04543a02e20bf04ab01c8dfc5e670a269d /tests | |
| parent | 791a3312a247670cdeed61e52e8ca449dbb27afa (diff) | |
| parent | 843499915e91e0ee324a0407c78ac6f570806370 (diff) | |
| download | sqlparse-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.py | 20 |
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 |
