diff --git a/tests/conftest.py b/tests/conftest.py index d5621eb4..38fe5c68 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -39,3 +39,11 @@ def make_load_file(filename, encoding='utf-8'): return f.read() return make_load_file + + +@pytest.fixture() +def get_stream(filepath): + def make_stream(filename, encoding='utf-8'): + return io.open(filepath(filename), encoding=encoding) + + return make_stream diff --git a/tests/files/stream.sql b/tests/files/stream.sql new file mode 100644 index 00000000..c1b73b03 --- /dev/null +++ b/tests/files/stream.sql @@ -0,0 +1,2 @@ +-- this file is streamed in +insert into foo diff --git a/tests/test_regressions.py b/tests/test_regressions.py index 255493c8..5d041315 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -184,6 +184,12 @@ def test_format_accepts_encoding(load_file): assert formatted == tformatted +def test_stream(get_stream): + stream = get_stream("stream.sql") + p = sqlparse.parse(stream)[0] + assert p.get_type() == 'INSERT' + + def test_issue90(): sql = ('UPDATE "gallery_photo" SET "owner_id" = 4018, "deleted_at" = NULL,' ' "width" = NULL, "height" = NULL, "rating_votes" = 0,'