-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathtest_warnings.py
31 lines (25 loc) · 901 Bytes
/
test_warnings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# encoding: utf-8
import uuid
from tornado import gen
from tornado.testing import gen_test
from . import BaseTestCase
class TestWarnings(BaseTestCase):
@gen.coroutine
def _execute_test0(self):
connection = yield self.pool.Connection()
warnings = yield connection.show_warnings()
connection.close()
self.assertEqual(warnings, (), "No warnings")
@gen.coroutine
def _execute_test1(self):
name = uuid.uuid4().hex
sql = 'DROP TABLE IF EXISTS test_{name}'.format(name=name)
with (yield self.pool.Connection()) as connection:
with connection.cursor() as cursor:
yield cursor.execute(sql)
warnings = yield connection.show_warnings()
self.assertTrue(name in warnings[0][2])
@gen_test
def test(self):
yield self._execute_test0()
yield self._execute_test1()