コード例 #1
0
ファイル: bdd_test.py プロジェクト: swipswaps/dd
def test_reordering_context():
    ctx = Dummy()
    # top context
    ctx.assert_(False)
    with _bdd._ReorderingContext(ctx):
        ctx.assert_(True)
        raise _bdd._NeedsReordering()
    ctx.assert_(False)
    # nested context
    ctx._reordering_context = True
    with nt.assert_raises(_bdd._NeedsReordering):
        with _bdd._ReorderingContext(ctx):
            ctx.assert_(True)
            raise _bdd._NeedsReordering()
    ctx.assert_(True)
    # other exception
    ctx._reordering_context = False
    with nt.assert_raises(AssertionError):
        with _bdd._ReorderingContext(ctx):
            ctx.assert_(True)
            raise AssertionError()
    ctx.assert_(False)
    ctx._reordering_context = True
    with nt.assert_raises(Exception):
        with _bdd._ReorderingContext(ctx):
            raise Exception()
    ctx.assert_(True)
コード例 #2
0
ファイル: bdd_test.py プロジェクト: johnyf/dd
def test_reordering_context():
    ctx = Dummy()
    # top context
    ctx.assert_(False)
    with _bdd._ReorderingContext(ctx):
        ctx.assert_(True)
        raise _bdd._NeedsReordering()
    ctx.assert_(False)
    # nested context
    ctx._reordering_context = True
    with nt.assert_raises(_bdd._NeedsReordering):
        with _bdd._ReorderingContext(ctx):
            ctx.assert_(True)
            raise _bdd._NeedsReordering()
    ctx.assert_(True)
    # other exception
    ctx._reordering_context = False
    with nt.assert_raises(AssertionError):
        with _bdd._ReorderingContext(ctx):
            ctx.assert_(True)
            raise AssertionError()
    ctx.assert_(False)
    ctx._reordering_context = True
    with nt.assert_raises(Exception):
        with _bdd._ReorderingContext(ctx):
            raise Exception()
    ctx.assert_(True)