From 7631460377274f6a9e074c974e2d63dafb1938eb Mon Sep 17 00:00:00 2001 From: quest Date: Sat, 21 Apr 2012 19:57:26 +0200 Subject: We can now work with file-like objects. --- tests/test_split.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/test_split.py') diff --git a/tests/test_split.py b/tests/test_split.py index 29ee72e..c73d9d4 100644 --- a/tests/test_split.py +++ b/tests/test_split.py @@ -116,3 +116,18 @@ class SQLSplitTest(TestCaseBase): 'SELECT t FROM two') stmts = sqlparse.split(sql) self.assertEqual(len(stmts), 2) + + def test_split_stream(self): + import types + from cStringIO import StringIO + + stream = StringIO("SELECT 1; SELECT 2;") + stmts = sqlparse.splitstream(stream) + self.assertEqual(type(stmts), types.GeneratorType) + self.assertEqual(len(list(stmts)), 2) + + def test_encoding_splitstream(self): + from cStringIO import StringIO + stream = StringIO("SELECT 1; SELECT 2;") + stmts = list(sqlparse.splitstream(stream)) + self.assertEqual(type(stmts[0].tokens[0].value), unicode) -- cgit v1.2.1 From 13274ebb0d66b64363145bf23b6aa824845f61be Mon Sep 17 00:00:00 2001 From: quest Date: Sat, 21 Apr 2012 20:18:42 +0200 Subject: Always use a stream internally; makes things more readable. --- tests/test_split.py | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/test_split.py') diff --git a/tests/test_split.py b/tests/test_split.py index c73d9d4..574dd97 100644 --- a/tests/test_split.py +++ b/tests/test_split.py @@ -1,4 +1,3 @@ - # -*- coding: utf-8 -*- # Tests splitting functions. -- cgit v1.2.1 From 1e3fbade7c80d917b4d727e9cef781b21be2fdf6 Mon Sep 17 00:00:00 2001 From: quest Date: Sat, 21 Apr 2012 22:37:30 +0200 Subject: splitstream -> parsestream --- tests/test_split.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/test_split.py') diff --git a/tests/test_split.py b/tests/test_split.py index 574dd97..321fca2 100644 --- a/tests/test_split.py +++ b/tests/test_split.py @@ -121,12 +121,12 @@ class SQLSplitTest(TestCaseBase): from cStringIO import StringIO stream = StringIO("SELECT 1; SELECT 2;") - stmts = sqlparse.splitstream(stream) + stmts = sqlparse.parsestream(stream) self.assertEqual(type(stmts), types.GeneratorType) self.assertEqual(len(list(stmts)), 2) - def test_encoding_splitstream(self): + def test_encoding_parsestream(self): from cStringIO import StringIO stream = StringIO("SELECT 1; SELECT 2;") - stmts = list(sqlparse.splitstream(stream)) + stmts = list(sqlparse.parsestream(stream)) self.assertEqual(type(stmts[0].tokens[0].value), unicode) -- cgit v1.2.1