Code

Ticket #2519: sqlite3.py

File sqlite3.py, 658 bytes (added by Victor Ng <victor.ng@…>, 8 years ago)

unit tests to excercise the delegation patch to SQLiteCursorWrapper

Line 
1"""
2Test the django sqlite3 driver to make sure it properly loads/stores unicode
3
4>>> u_data = u'\xc5land islands'
5>>> db = DatabaseWrapper()
6>>> cur = db.cursor()
7
8We have to make sure we're using the 'real' sqlite cursor, not some
9debugcursor
10>>> assert isinstance(cur, SQLiteCursorWrapper)
11
12>>> cur.execute("create table foo (blah varchar)")
13>>> cur.execute("insert into foo (blah) values (%s)", [u_data])
14>>> cur.execute("select * from foo")
15>>> assert cur.fetchone()[0] == u_data
16
17"""
18
19
20from django.db.backends.sqlite3.base import DatabaseWrapper, SQLiteCursorWrapper
21import datetime
22
23if __name__ == '__main__':
24    import doctest
25    doctest.testmod()