Python code coverage for Doc/includes/sqlite3/countcursors.py
# | count | content |
---|---|---|
1 | n/a | import sqlite3 |
2 | n/a | |
3 | n/a | class CountCursorsConnection(sqlite3.Connection): |
4 | n/a | def __init__(self, *args, **kwargs): |
5 | n/a | sqlite3.Connection.__init__(self, *args, **kwargs) |
6 | n/a | self.numcursors = 0 |
7 | n/a | |
8 | n/a | def cursor(self, *args, **kwargs): |
9 | n/a | self.numcursors += 1 |
10 | n/a | return sqlite3.Connection.cursor(self, *args, **kwargs) |
11 | n/a | |
12 | n/a | con = sqlite3.connect(":memory:", factory=CountCursorsConnection) |
13 | n/a | cur1 = con.cursor() |
14 | n/a | cur2 = con.cursor() |
15 | n/a | print(con.numcursors) |