tests.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:django-sequences 作者: aaugustin 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号