annotate tests/test_MySQLdb_nonstandard.py @ 37:df4d804244ec MySQLdb

Since tests are easy to run, there's no reason to have them in shipping code.
author kylev
date Thu, 12 Feb 2009 00:36:39 +0000
parents 25c5d3b241ba
children 2d1a3d9e15b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
1 import unittest
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
2
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
3 import MySQLdb
37
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
4 from MySQLdb.constants import FIELD_TYPE
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
5
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
6
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
7 class TestDBAPISet(unittest.TestCase):
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
8 def test_set_equality(self):
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
9 self.assertTrue(MySQLdb.STRING == MySQLdb.STRING)
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
10
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
11 def test_set_inequality(self):
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
12 self.assertTrue(MySQLdb.STRING != MySQLdb.NUMBER)
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
13
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
14 def test_set_equality_membership(self):
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
15 self.assertTrue(FIELD_TYPE.VAR_STRING == MySQLdb.STRING)
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
16
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
17 def test_set_inequality_membership(self):
df4d804244ec Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents: 25
diff changeset
18 self.assertTrue(FIELD_TYPE.DATE != MySQLdb.STRING)
25
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
19
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
20
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
21 class NonStandard(unittest.TestCase):
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
22 """Test _mysql.connection internals."""
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
23
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
24 def setUp(self):
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
25 self.conn = MySQLdb.connect(db='test')
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
26
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
27 def tearDown(self):
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
28 self.conn.close()
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
29
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
30 def test_thread_id(self):
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
31 tid = self.conn._db.thread_id()
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
32 self.assertTrue(isinstance(tid, int),
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
33 "thread_id didn't return an int.")
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
34
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
35 self.assertRaises(TypeError, self.conn._db.thread_id, ('evil',),
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
36 "thread_id shouldn't accept arguments.")
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
37
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
38 def test_affected_rows(self):
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
39 self.assertEquals(self.conn._db.affected_rows(), 0,
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
40 "Should return 0 before we do anything.")
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
41
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
42
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
43 def test_debug(self):
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
44 # FIXME Only actually tests if you lack SUPER
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
45 self.assertRaises(MySQLdb.OperationalError,
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
46 self.conn._db.dump_debug_info)
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
47
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
48 def test_charset_name(self):
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
49 self.assertTrue(isinstance(self.conn._db.character_set_name(), str),
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
50 "Should return a string.")
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
51
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
52 def test_host_info(self):
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
53 self.assertTrue(isinstance(self.conn._db.get_host_info(), str),
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
54 "Should return a string.")
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
55
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
56 def test_proto_info(self):
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
57 self.assertTrue(isinstance(self.conn._db.get_proto_info(), int),
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
58 "Should return an int.")
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
59
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
60 def test_server_info(self):
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
61 self.assertTrue(isinstance(self.conn._db.get_server_info(), str),
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
62 "Should return an str.")
25c5d3b241ba Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff changeset
63