@@ -15,6 +15,9 @@ def test_keywordcase(self):
1515 assert res == 'Select * From bar; -- select foo\n '
1616 res = sqlparse .format (sql .upper (), keyword_case = 'lower' )
1717 assert res == 'select * from BAR; -- SELECT FOO\n '
18+
19+ def test_keywordcase_invalid_option (self ):
20+ sql = 'select * from bar; -- select foo\n '
1821 with pytest .raises (SQLParseError ):
1922 sqlparse .format (sql , keyword_case = 'foo' )
2023
@@ -26,11 +29,16 @@ def test_identifiercase(self):
2629 assert res == 'select * from Bar; -- select foo\n '
2730 res = sqlparse .format (sql .upper (), identifier_case = 'lower' )
2831 assert res == 'SELECT * FROM bar; -- SELECT FOO\n '
32+
33+ def test_identifiercase_invalid_option (self ):
34+ sql = 'select * from bar; -- select foo\n '
35+ with pytest .raises (SQLParseError ):
36+ sqlparse .format (sql , identifier_case = 'foo' )
37+
38+ def test_identifiercase_quotes (self ):
2939 sql = 'select * from "foo"."bar"'
3040 res = sqlparse .format (sql , identifier_case = "upper" )
3141 assert res == 'select * from "foo"."bar"'
32- with pytest .raises (SQLParseError ):
33- sqlparse .format (sql , identifier_case = 'foo' )
3442
3543 def test_strip_comments_single (self ):
3644 sql = 'select *-- statement starts here\n from foo'
@@ -42,6 +50,9 @@ def test_strip_comments_single(self):
4250 sql = 'select-- foo\n from -- bar\n where'
4351 res = sqlparse .format (sql , strip_comments = True )
4452 assert res == 'select from where'
53+
54+ def test_strip_comments_invalid_option (self ):
55+ sql = 'select-- foo\n from -- bar\n where'
4556 with pytest .raises (SQLParseError ):
4657 sqlparse .format (sql , strip_comments = None )
4758
@@ -68,6 +79,9 @@ def test_strip_ws(self):
6879 assert f (s ) == 'select * from foo where (1 = 2)'
6980 s = 'select -- foo\n from bar\n '
7081 assert f (s ) == 'select -- foo\n from bar'
82+
83+ def test_strip_ws_invalid_option (self ):
84+ s = 'select -- foo\n from bar\n '
7185 with pytest .raises (SQLParseError ):
7286 sqlparse .format (s , strip_whitespace = None )
7387
@@ -95,11 +109,6 @@ def test_notransform_of_quoted_crlf(self):
95109 assert (f (s4 ) ==
96110 "SELECT some_column LIKE 'value\\ \\ \\ '\r ' WHERE id = 1\n " )
97111
98- def test_outputformat (self ):
99- sql = 'select * from foo;'
100- with pytest .raises (SQLParseError ):
101- sqlparse .format (sql , output_format = 'foo' )
102-
103112
104113class TestFormatReindentAligned (object ):
105114 @staticmethod
@@ -546,6 +555,11 @@ def test_sql(self):
546555 f = lambda sql : sqlparse .format (sql , output_format = 'sql' )
547556 assert f (sql ) == 'select * from foo;'
548557
558+ def test_invalid_option (self ):
559+ sql = 'select * from foo;'
560+ with pytest .raises (SQLParseError ):
561+ sqlparse .format (sql , output_format = 'foo' )
562+
549563
550564def test_format_column_ordering ():
551565 # issue89
@@ -596,7 +610,7 @@ def test_having_produces_newline():
596610
597611
598612@pytest .mark .parametrize ('right_margin' , ['ten' , 2 ])
599- def test_format_right_margin_invalid_input (right_margin ):
613+ def test_format_right_margin_invalid_option (right_margin ):
600614 with pytest .raises (SQLParseError ):
601615 sqlparse .format ('foo' , right_margin = right_margin )
602616
0 commit comments