diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_MySQLdb_nonstandard.py	Sat Feb 07 20:42:50 2009 +0000
@@ -0,0 +1,48 @@
+import unittest
+
+import MySQLdb
+
+
+class NonStandard(unittest.TestCase):
+    """Test _mysql.connection internals."""
+
+    def setUp(self):
+        self.conn = MySQLdb.connect(db='test')
+
+    def tearDown(self):
+        self.conn.close()
+
+    def test_thread_id(self):
+        tid = self.conn._db.thread_id()
+        self.assertTrue(isinstance(tid, int),
+                        "thread_id didn't return an int.")
+
+        self.assertRaises(TypeError, self.conn._db.thread_id, ('evil',),
+                          "thread_id shouldn't accept arguments.")
+
+    def test_affected_rows(self):
+        self.assertEquals(self.conn._db.affected_rows(), 0,
+                          "Should return 0 before we do anything.")
+
+
+    def test_debug(self):
+        # FIXME Only actually tests if you lack SUPER
+        self.assertRaises(MySQLdb.OperationalError,
+                          self.conn._db.dump_debug_info)
+
+    def test_charset_name(self):
+        self.assertTrue(isinstance(self.conn._db.character_set_name(), str),
+                        "Should return a string.")
+
+    def test_host_info(self):
+        self.assertTrue(isinstance(self.conn._db.get_host_info(), str),
+                        "Should return a string.")
+
+    def test_proto_info(self):
+        self.assertTrue(isinstance(self.conn._db.get_proto_info(), int),
+                        "Should return an int.")
+
+    def test_server_info(self):
+        self.assertTrue(isinstance(self.conn._db.get_server_info(), str),
+                        "Should return an str.")
+