From 4d05b441fcb801d320ac52ce90465b74d419ceac Mon Sep 17 00:00:00 2001 From: Andi Albrecht Date: Wed, 14 Sep 2016 18:42:22 +0200 Subject: Add formatter option for comma first notation (fixes #141). --- tests/test_format.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/test_format.py b/tests/test_format.py index 023f26d..67377ab 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -322,6 +322,8 @@ class TestFormatReindent(object): sqlparse.format('foo', reindent=True, wrap_after='foo') with pytest.raises(SQLParseError): sqlparse.format('foo', reindent=True, wrap_after=-12) + with pytest.raises(SQLParseError): + sqlparse.format('foo', reindent=True, comma_first='foo') def test_stmts(self): f = lambda sql: sqlparse.format(sql, reindent=True) @@ -428,6 +430,19 @@ class TestFormatReindent(object): 'from table1, table2', 'where 1 = 2']) + def test_identifier_list_comment_first(self): + f = lambda sql: sqlparse.format(sql, reindent=True, comma_first=True) + # not the 3: It cleans up whitespace too! + s = 'select foo, bar, baz from table where foo in (1, 2,3)' + assert f(s) == '\n'.join([ + 'select foo', + ' , bar', + ' , baz', + 'from table', + 'where foo in (1', + ' , 2', + ' , 3)']) + def test_identifier_list_with_functions(self): f = lambda sql: sqlparse.format(sql, reindent=True) s = ("select 'abc' as foo, coalesce(col1, col2)||col3 as bar," -- cgit v1.2.1