def test_second_cursor(self):
"""
Dict's cursor should not interfere with another cursor.
"""
Person = self.db['person']
bob = Person(name='Bob').flush()
aly = Person(name='Aly').flush()
self.assertDictContains(bob, {'name':'Bob', 'id':1})
curs2 = self.conn.cursor(cursor_factory=DictCursor)
persons = Person.get_where()
self.assertEqual(next(persons), bob)
curs2.execute('SELECT * FROM person')
self.assertEqual(next(persons), aly)
# Using dictorm's cursor will intefere
persons = Person.get_where()
self.assertEqual(next(persons), bob)
persons.curs.execute('SELECT * FROM person')
self.assertEqual(next(persons), bob)
self.assertEqual(next(persons), aly)
self.assertRaises(StopIteration, next, persons)
评论列表
文章目录