diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2013-04-04 05:54:43 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2013-04-04 05:54:43 +0200 |
| commit | 081b23757c1a534baf42f7c099bab471bf20fe83 (patch) | |
| tree | f751d0eb5f754117bcdf6767cf2600b1f67def62 /tests | |
| parent | e664ae1da02f87f720878c7699cc26d0a8e9e659 (diff) | |
| download | sqlparse-081b23757c1a534baf42f7c099bab471bf20fe83.tar.gz | |
Add encoding parameter to top-level functions (fixes issue20).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/files/test_cp1251.sql | 1 | ||||
| -rw-r--r-- | tests/test_regressions.py | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/tests/files/test_cp1251.sql b/tests/files/test_cp1251.sql new file mode 100644 index 0000000..6c0228b --- /dev/null +++ b/tests/files/test_cp1251.sql @@ -0,0 +1 @@ +insert into foo values (1); -- diff --git a/tests/test_regressions.py b/tests/test_regressions.py index 94d644f..e9d890b 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -2,7 +2,7 @@ import sys -from tests.utils import TestCaseBase +from tests.utils import TestCaseBase, load_file import sqlparse from sqlparse import sql @@ -188,3 +188,13 @@ def test_dont_alias_keywords(): assert len(p.tokens) == 5 assert p.tokens[0].ttype is T.Keyword assert p.tokens[2].ttype is T.Keyword + + +def test_format_accepts_encoding(): # issue20 + sql = load_file('test_cp1251.sql', 'cp1251') + formatted = sqlparse.format(sql, reindent=True, encoding='cp1251') + if sys.version_info < (3,): + tformatted = u'insert into foo\nvalues (1); -- Песня про надежду\n' + else: + tformatted = 'insert into foo\nvalues (1); -- Песня про надежду\n' + assert formatted == tformatted |
