diff options
| author | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-19 14:20:25 -0700 |
|---|---|---|
| committer | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-20 07:41:13 -0700 |
| commit | 8ebd43d8109c6ecaf4964634e3bd782e8bd769d5 (patch) | |
| tree | 892c56b4a2699ee790a66872d58a925acfd10bc7 /tests/test_split.py | |
| parent | 5d50f349cda37986bb3704e8fe25d57c78e6047a (diff) | |
| download | sqlparse-8ebd43d8109c6ecaf4964634e3bd782e8bd769d5.tar.gz | |
Parametrize tests
Allows for tests to continue if the first assert had failed.
In particular useful when certain change is dealing with two
almost opposing edge cases.
Diffstat (limited to 'tests/test_split.py')
| -rw-r--r-- | tests/test_split.py | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/tests/test_split.py b/tests/test_split.py index 8a2fe2d..af7c9ce 100644 --- a/tests/test_split.py +++ b/tests/test_split.py @@ -4,7 +4,7 @@ import types -import pytest # noqa +import pytest import sqlparse from sqlparse.compat import StringIO, text_type @@ -24,34 +24,17 @@ def test_split_backslash(): assert len(stmts) == 3 -def test_split_create_function(load_file): - sql = load_file('function.sql') - stmts = sqlparse.parse(sql) - assert len(stmts) == 1 - assert str(stmts[0]) == sql - - -def test_split_create_function_psql(load_file): - sql = load_file('function_psql.sql') +@pytest.mark.parametrize('fn', ['function.sql', + 'function_psql.sql', + 'function_psql2.sql', + 'function_psql3.sql']) +def test_split_create_function(load_file, fn): + sql = load_file(fn) stmts = sqlparse.parse(sql) assert len(stmts) == 1 assert text_type(stmts[0]) == sql -def test_split_create_function_psql3(load_file): - sql = load_file('function_psql3.sql') - stmts = sqlparse.parse(sql) - assert len(stmts) == 1 - assert str(stmts[0]) == sql - - -def test_split_create_function_psql2(load_file): - sql = load_file('function_psql2.sql') - stmts = sqlparse.parse(sql) - assert len(stmts) == 1 - assert str(stmts[0]) == sql - - def test_split_dashcomments(load_file): sql = load_file('dashcomment.sql') stmts = sqlparse.parse(sql) @@ -59,14 +42,12 @@ def test_split_dashcomments(load_file): assert ''.join(str(q) for q in stmts) == sql -def test_split_dashcomments_eol(): - stmts = sqlparse.parse('select foo; -- comment\n') - assert len(stmts) == 1 - stmts = sqlparse.parse('select foo; -- comment\r') - assert len(stmts) == 1 - stmts = sqlparse.parse('select foo; -- comment\r\n') - assert len(stmts) == 1 - stmts = sqlparse.parse('select foo; -- comment') +@pytest.mark.parametrize('s', ['select foo; -- comment\n', + 'select foo; -- comment\r', + 'select foo; -- comment\r\n', + 'select foo; -- comment']) +def test_split_dashcomments_eol(s): + stmts = sqlparse.parse(s) assert len(stmts) == 1 |
