summaryrefslogtreecommitdiff
path: root/tests/test_parse.py
diff options
context:
space:
mode:
authorVictor Uriarte <victor.m.uriarte@intel.com>2016-06-10 19:53:07 -0700
committerVictor Uriarte <victor.m.uriarte@intel.com>2016-06-11 04:34:16 -0700
commit226e13f5724f8d87ac6359757a0cde180aa50b51 (patch)
treea6d69dcaeab66683b594b64640826f9dad48c079 /tests/test_parse.py
parent0c468f5947741c0583330535e62c361f3a6af5ed (diff)
downloadsqlparse-226e13f5724f8d87ac6359757a0cde180aa50b51.tar.gz
Add pprint_test
Diffstat (limited to 'tests/test_parse.py')
-rw-r--r--tests/test_parse.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_parse.py b/tests/test_parse.py
index cc51a5d..146168b 100644
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -9,7 +9,7 @@ from tests.utils import TestCaseBase
import sqlparse
import sqlparse.sql
from sqlparse import tokens as T
-from sqlparse.compat import u
+from sqlparse.compat import u, StringIO
class SQLParseTest(TestCaseBase):
@@ -315,3 +315,22 @@ def test_get_token_at_offset():
assert p.get_token_at_offset(8) == p.tokens[3]
assert p.get_token_at_offset(9) == p.tokens[4]
assert p.get_token_at_offset(10) == p.tokens[4]
+
+
+def test_pprint():
+ p = sqlparse.parse('select * from dual')[0]
+ output = StringIO()
+
+ p._pprint_tree(f=output)
+ pprint = u'\n'.join([
+ " | 0 DML 'select'",
+ " | 1 Whitespace ' '",
+ " | 2 Wildcard '*'",
+ " | 3 Whitespace ' '",
+ " | 4 Keyword 'from'",
+ " | 5 Whitespace ' '",
+ " +-6 Identifier 'dual'",
+ " | 0 Name 'dual'",
+ "",
+ ])
+ assert output.getvalue() == pprint