]> git.phdru.name Git - sqlconvert.git/commitdiff
Add a test for print_tokens()
authorOleg Broytman <phd@phdru.name>
Mon, 26 Sep 2016 21:54:23 +0000 (00:54 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 26 Sep 2016 21:54:23 +0000 (00:54 +0300)
ChangeLog
tests/test_print_tokens.py [new file with mode: 0644]

index d84b6372b82590edfebe5e6a3440fa1d6da205c9..7a15d548abd17b65b8d9b41ad5f391631b2a96c2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@ Version 0.0.7 (2016-09-??)
 
    Change quoting style to MySQL, PostgreSQL or SQLite.
 
+   Add a test for print_tokens().
+
 Version 0.0.6 (2016-09-25)
 
    Condense a sequence of newlines after a /*! directive */;
diff --git a/tests/test_print_tokens.py b/tests/test_print_tokens.py
new file mode 100644 (file)
index 0000000..af9c9ae
--- /dev/null
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+
+try:
+    from cStringIO import StringIO
+except ImportError:
+    try:
+        from StringIO import StringIO
+    except ImportError:
+        from io import StringIO
+
+from sqlparse import parse
+from sqlconvert.print_tokens import print_tokens
+
+
+def test_print_tokens():
+    sio = StringIO()
+    parsed = parse("select * from T")[0]
+    print_tokens(parsed, outfile=sio)
+    assert sio.getvalue() == u"SELECT * FROM T"