Mercurial > p > mysql-python > mysqldb-2
annotate tests/test_MySQLdb_nonstandard.py @ 40:2d1a3d9e15b2 MySQLdb
Update some of the constants and declarations to post python-2.0
convenience functions, increase related test coverage.
author | kylev |
---|---|
date | Sun, 15 Feb 2009 07:26:43 +0000 |
parents | df4d804244ec |
children | e80676c3505f |
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 |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
3 import _mysql |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
4 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
|
5 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
|
6 |
df4d804244ec
Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents:
25
diff
changeset
|
7 |
df4d804244ec
Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents:
25
diff
changeset
|
8 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
|
9 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
|
10 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
|
11 |
df4d804244ec
Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents:
25
diff
changeset
|
12 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
|
13 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
|
14 |
df4d804244ec
Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents:
25
diff
changeset
|
15 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
|
16 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
|
17 |
df4d804244ec
Since tests are easy to run, there's no reason to have them in shipping code.
kylev
parents:
25
diff
changeset
|
18 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
|
19 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
|
20 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
21 |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
22 class CoreAPI(unittest.TestCase): |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
23 """Test _mysql internals.""" |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
24 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
25 def setUp(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
26 self.conn = _mysql.connect(db='test') |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
27 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
28 def tearDown(self): |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
29 self.conn.close() |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
30 |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
31 def test_NULL(self): |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
32 """Should have a NULL constant.""" |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
33 self.assertEqual(_mysql.NULL, 'NULL') |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
34 |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
35 def test_version(self): |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
36 """Version information sanity.""" |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
37 self.assertTrue(isinstance(_mysql.__version__, str)) |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
38 |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
39 self.assertTrue(isinstance(_mysql.version_info, tuple)) |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
40 self.assertEqual(len(_mysql.version_info), 5) |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
41 |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
42 def test_thread_id(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
43 tid = self.conn.thread_id() |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
44 self.assertTrue(isinstance(tid, int), |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
45 "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
|
46 |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
47 self.assertRaises(TypeError, self.conn.thread_id, ('evil',), |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
48 "thread_id shouldn't accept arguments.") |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
49 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
50 def test_affected_rows(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
51 self.assertEquals(self.conn.affected_rows(), 0, |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
52 "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
|
53 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
54 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
55 def test_debug(self): |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
56 # 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
|
57 self.assertRaises(MySQLdb.OperationalError, |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
58 self.conn.dump_debug_info) |
25
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_charset_name(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
61 self.assertTrue(isinstance(self.conn.character_set_name(), str), |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
62 "Should return a string.") |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
63 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
64 def test_host_info(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
65 self.assertTrue(isinstance(self.conn.get_host_info(), str), |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
66 "Should return a string.") |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
67 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
68 def test_proto_info(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
69 self.assertTrue(isinstance(self.conn.get_proto_info(), int), |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
70 "Should return an int.") |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
71 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
72 def test_server_info(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
73 self.assertTrue(isinstance(self.conn.get_server_info(), str), |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
74 "Should return an str.") |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
75 |