summaryrefslogtreecommitdiff
path: root/tests/test_split.py
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@googlemail.com>2012-04-21 21:28:03 -0700
committerAndi Albrecht <albrecht.andi@googlemail.com>2012-04-21 21:28:03 -0700
commit9b643b52bfd59b583094d08615c7bd698f98e576 (patch)
tree5d13bc4428bf678c75e0cbbdf1e35ec5655788ee /tests/test_split.py
parent0afebf47e24d8a1ee1981faef39c0a15a798f7fd (diff)
parenta16c08703c8eb213a8b570bb16636fbe7a2b4a28 (diff)
downloadsqlparse-9b643b52bfd59b583094d08615c7bd698f98e576.tar.gz
Merge pull request #63 from bittrance/master
Support for reading from file-like object
Diffstat (limited to 'tests/test_split.py')
-rw-r--r--tests/test_split.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_split.py b/tests/test_split.py
index 29ee72e..321fca2 100644
--- a/tests/test_split.py
+++ b/tests/test_split.py
@@ -1,4 +1,3 @@
-
# -*- coding: utf-8 -*-
# Tests splitting functions.
@@ -116,3 +115,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.parsestream(stream)
+ self.assertEqual(type(stmts), types.GeneratorType)
+ self.assertEqual(len(list(stmts)), 2)
+
+ def test_encoding_parsestream(self):
+ from cStringIO import StringIO
+ stream = StringIO("SELECT 1; SELECT 2;")
+ stmts = list(sqlparse.parsestream(stream))
+ self.assertEqual(type(stmts[0].tokens[0].value), unicode)