Mercurial > p > mysql-python > mysqldb-2
annotate tests/test_MySQLdb_nonstandard.py @ 52:4aaed7e1d782 MySQLdb
test_LONG and test_TEXT are failing but I can't see why yet
author | adustman |
---|---|
date | Sun, 22 Feb 2009 20:38:12 +0000 |
parents | f4fd8c20511c |
children |
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 |
41 | 22 class CoreModule(unittest.TestCase): |
23 """Core _mysql module features.""" | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
24 |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
25 def test_NULL(self): |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
26 """Should have a NULL constant.""" |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
27 self.assertEqual(_mysql.NULL, 'NULL') |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
28 |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
29 def test_version(self): |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
30 """Version information sanity.""" |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
31 self.assertTrue(isinstance(_mysql.__version__, str)) |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
32 |
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
33 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
|
34 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
|
35 |
41 | 36 def test_client_info(self): |
37 self.assertTrue(isinstance(_mysql.get_client_info(), str)) | |
38 | |
39 def test_thread_safe(self): | |
40 self.assertTrue(isinstance(_mysql.thread_safe(), int)) | |
41 | |
42 | |
43 class CoreAPI(unittest.TestCase): | |
44 """Test _mysql interaction internals.""" | |
45 | |
46 def setUp(self): | |
48
f4fd8c20511c
Read a default file in the test setUp. Since Python 2.4, int() will return longs if needed so make all long references int as in Python 3.0 there is no more long due to int/long unification (new ints are old longs).
adustman
parents:
41
diff
changeset
|
47 self.conn = _mysql.connect(db='test', read_default_file="~/.my.cnf") |
41 | 48 |
49 def tearDown(self): | |
50 self.conn.close() | |
51 | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
52 def test_thread_id(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
53 tid = self.conn.thread_id() |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
54 self.assertTrue(isinstance(tid, int), |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
55 "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
|
56 |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
57 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
|
58 "thread_id shouldn't accept arguments.") |
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_affected_rows(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
61 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
|
62 "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
|
63 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
64 |
52
4aaed7e1d782
test_LONG and test_TEXT are failing but I can't see why yet
adustman
parents:
48
diff
changeset
|
65 #def test_debug(self): |
4aaed7e1d782
test_LONG and test_TEXT are failing but I can't see why yet
adustman
parents:
48
diff
changeset
|
66 ## FIXME Only actually tests if you lack SUPER |
4aaed7e1d782
test_LONG and test_TEXT are failing but I can't see why yet
adustman
parents:
48
diff
changeset
|
67 #self.assertRaises(MySQLdb.OperationalError, |
4aaed7e1d782
test_LONG and test_TEXT are failing but I can't see why yet
adustman
parents:
48
diff
changeset
|
68 #self.conn.dump_debug_info) |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
69 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
70 def test_charset_name(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
71 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
|
72 "Should return a string.") |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
73 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
74 def test_host_info(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
75 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
|
76 "Should return a string.") |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
77 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
78 def test_proto_info(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
79 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
|
80 "Should return an int.") |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
81 |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
82 def test_server_info(self): |
40
2d1a3d9e15b2
Update some of the constants and declarations to post python-2.0
kylev
parents:
37
diff
changeset
|
83 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
|
84 "Should return an str.") |
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
diff
changeset
|
85 |