]> git.phdru.name Git - sqlconvert.git/blob - tests/test_print_tokens.py
Move hard requirements from tox.ini to requirements.txt
[sqlconvert.git] / tests / test_print_tokens.py
1 # -*- coding: utf-8 -*-
2
3 try:
4     from io import StringIO, BytesIO
5 except ImportError:
6     try:
7         from cStringIO import StringIO
8     except ImportError:
9         from StringIO import StringIO
10     BytesIO = StringIO
11
12 from sqlparse import parse
13 from sqlconvert.print_tokens import print_tokens
14
15
16 def test_print_tokens():
17     sio = StringIO()
18     parsed = parse("select * from T")[0]
19     print_tokens(parsed, outfile=sio)
20     assert sio.getvalue() == u"SELECT * FROM T"
21
22
23 def test_print_tokens_encoded():
24     sio = BytesIO()
25     parsed = parse("select * from T")[0]
26     print_tokens(parsed, outfile=sio, encoding='ascii')
27     assert sio.getvalue() == b"SELECT * FROM T"