def test_later_access_nowait(self):
get_next_value()
def one(output):
with transaction.atomic():
value = get_next_value()
output.append(('one', value))
time.sleep(0.5)
connection.close()
def two(output):
time.sleep(0.1)
with self.assertRaises(OperationalError):
with transaction.atomic():
value = get_next_value(nowait=True)
output.append(('two', value)) # shouldn't be reached
output.append(('two', 'exc'))
connection.close()
expected = [
('one', 2),
('two', 'exc'),
]
self.assertSequence(one, two, expected)
评论列表
文章目录