comparison tests/test_MySQLdb_nonstandard.py @ 25:25c5d3b241ba MySQLdb

Start converting some some things to METH_NOARGS to save invocation time, add a few tests to directly probe these internals. SF Patch ID 2565515
author kylev
date Sat, 07 Feb 2009 20:42:50 +0000
parents
children df4d804244ec
comparison
equal deleted inserted replaced
24:2f4672764d39 25:25c5d3b241ba
1 import unittest
2
3 import MySQLdb
4
5
6 class NonStandard(unittest.TestCase):
7 """Test _mysql.connection internals."""
8
9 def setUp(self):
10 self.conn = MySQLdb.connect(db='test')
11
12 def tearDown(self):
13 self.conn.close()
14
15 def test_thread_id(self):
16 tid = self.conn._db.thread_id()
17 self.assertTrue(isinstance(tid, int),
18 "thread_id didn't return an int.")
19
20 self.assertRaises(TypeError, self.conn._db.thread_id, ('evil',),
21 "thread_id shouldn't accept arguments.")
22
23 def test_affected_rows(self):
24 self.assertEquals(self.conn._db.affected_rows(), 0,
25 "Should return 0 before we do anything.")
26
27
28 def test_debug(self):
29 # FIXME Only actually tests if you lack SUPER
30 self.assertRaises(MySQLdb.OperationalError,
31 self.conn._db.dump_debug_info)
32
33 def test_charset_name(self):
34 self.assertTrue(isinstance(self.conn._db.character_set_name(), str),
35 "Should return a string.")
36
37 def test_host_info(self):
38 self.assertTrue(isinstance(self.conn._db.get_host_info(), str),
39 "Should return a string.")
40
41 def test_proto_info(self):
42 self.assertTrue(isinstance(self.conn._db.get_proto_info(), int),
43 "Should return an int.")
44
45 def test_server_info(self):
46 self.assertTrue(isinstance(self.conn._db.get_server_info(), str),
47 "Should return an str.")
48