diff options
| author | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-19 15:14:17 -0700 |
|---|---|---|
| committer | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-20 07:41:13 -0700 |
| commit | 3aa952d71952cbb0728698bb381dae74d1a1727b (patch) | |
| tree | 9c23d6eaebbc94f1881d3d084e6dbec99cbe7701 | |
| parent | 8ebd43d8109c6ecaf4964634e3bd782e8bd769d5 (diff) | |
| download | sqlparse-3aa952d71952cbb0728698bb381dae74d1a1727b.tar.gz | |
Split test/asserts that are weakly related
| -rw-r--r-- | tests/test_format.py | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/tests/test_format.py b/tests/test_format.py index 6cf4973..023f26d 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -15,6 +15,9 @@ class TestFormat(object): assert res == 'Select * From bar; -- select foo\n' res = sqlparse.format(sql.upper(), keyword_case='lower') assert res == 'select * from BAR; -- SELECT FOO\n' + + def test_keywordcase_invalid_option(self): + sql = 'select * from bar; -- select foo\n' with pytest.raises(SQLParseError): sqlparse.format(sql, keyword_case='foo') @@ -26,11 +29,16 @@ class TestFormat(object): assert res == 'select * from Bar; -- select foo\n' res = sqlparse.format(sql.upper(), identifier_case='lower') assert res == 'SELECT * FROM bar; -- SELECT FOO\n' + + def test_identifiercase_invalid_option(self): + sql = 'select * from bar; -- select foo\n' + with pytest.raises(SQLParseError): + sqlparse.format(sql, identifier_case='foo') + + def test_identifiercase_quotes(self): sql = 'select * from "foo"."bar"' res = sqlparse.format(sql, identifier_case="upper") assert res == 'select * from "foo"."bar"' - with pytest.raises(SQLParseError): - sqlparse.format(sql, identifier_case='foo') def test_strip_comments_single(self): sql = 'select *-- statement starts here\nfrom foo' @@ -42,6 +50,9 @@ class TestFormat(object): sql = 'select-- foo\nfrom -- bar\nwhere' res = sqlparse.format(sql, strip_comments=True) assert res == 'select from where' + + def test_strip_comments_invalid_option(self): + sql = 'select-- foo\nfrom -- bar\nwhere' with pytest.raises(SQLParseError): sqlparse.format(sql, strip_comments=None) @@ -68,6 +79,9 @@ class TestFormat(object): assert f(s) == 'select * from foo where (1 = 2)' s = 'select -- foo\nfrom bar\n' assert f(s) == 'select -- foo\nfrom bar' + + def test_strip_ws_invalid_option(self): + s = 'select -- foo\nfrom bar\n' with pytest.raises(SQLParseError): sqlparse.format(s, strip_whitespace=None) @@ -95,11 +109,6 @@ class TestFormat(object): assert (f(s4) == "SELECT some_column LIKE 'value\\\\\\'\r' WHERE id = 1\n") - def test_outputformat(self): - sql = 'select * from foo;' - with pytest.raises(SQLParseError): - sqlparse.format(sql, output_format='foo') - class TestFormatReindentAligned(object): @staticmethod @@ -546,6 +555,11 @@ class TestOutputFormat(object): f = lambda sql: sqlparse.format(sql, output_format='sql') assert f(sql) == 'select * from foo;' + def test_invalid_option(self): + sql = 'select * from foo;' + with pytest.raises(SQLParseError): + sqlparse.format(sql, output_format='foo') + def test_format_column_ordering(): # issue89 @@ -596,7 +610,7 @@ def test_having_produces_newline(): @pytest.mark.parametrize('right_margin', ['ten', 2]) -def test_format_right_margin_invalid_input(right_margin): +def test_format_right_margin_invalid_option(right_margin): with pytest.raises(SQLParseError): sqlparse.format('foo', right_margin=right_margin) |
