ยปCore Development>Code coverage>Doc/includes/sqlite3/countcursors.py

Python code coverage for Doc/includes/sqlite3/countcursors.py

#countcontent
1n/aimport sqlite3
2n/a
3n/aclass CountCursorsConnection(sqlite3.Connection):
4n/a def __init__(self, *args, **kwargs):
5n/a sqlite3.Connection.__init__(self, *args, **kwargs)
6n/a self.numcursors = 0
7n/a
8n/a def cursor(self, *args, **kwargs):
9n/a self.numcursors += 1
10n/a return sqlite3.Connection.cursor(self, *args, **kwargs)
11n/a
12n/acon = sqlite3.connect(":memory:", factory=CountCursorsConnection)
13n/acur1 = con.cursor()
14n/acur2 = con.cursor()
15n/aprint(con.numcursors)