示例#1
0
def test_push_unknown():
    ctx = Context()

    needle = 'xyzzy'
    assert needle not in _default_context.keys()

    with pytest.raises(KeyError):

        ctx.push(**{needle: Nothing})
    with pytest.raises(RuntimeError):
        ctx.pop()
示例#2
0
def test_push_known():
    ctx = Context()

    needle = _default_context.keys()[0]
    assert needle in ctx
    assert ctx[needle] is not Nothing

    ctx.push(**{needle.encode('ascii'): Nothing})
    assert ctx[needle] is Nothing

    ctx.pop()
    assert ctx[needle] is not Nothing
示例#3
0
def test_push_known():
    ctx = Context()

    needle = _default_context.keys()[0]
    assert needle in ctx
    assert ctx[needle] is not Nothing

    ctx.push(**{needle.encode('ascii'): Nothing})
    assert ctx[needle] is Nothing

    ctx.pop()
    assert ctx[needle] is not Nothing
示例#4
0
def test_push_known():
    ctx = Context()

    needle = list(_default_context.keys())[0]
    assert needle in ctx
    assert ctx[needle] is not Nothing

    ctx.push(**{needle: Nothing})
    assert ctx[needle] is Nothing

    ctx.pop()
    assert ctx[needle] is not Nothing
示例#5
0
def test_push_known():
    ctx = Context()

    needle = list(_default_context.keys())[0]
    assert needle in ctx
    assert ctx[needle] is not Nothing

    ctx.push(**{needle: Nothing})
    assert ctx[needle] is Nothing

    ctx.pop()
    assert ctx[needle] is not Nothing
示例#6
0
def test_stack_plain_push_pop():
    ctx = Context()

    needle, initial_value = _default_context.items()[0]
    assert ctx[needle] == initial_value

    ctx.push()
    assert ctx[needle] == initial_value
    ctx[needle] = Nothing
    assert ctx[needle] is Nothing

    ctx.pop()
    assert ctx[needle] is not Nothing
    assert ctx[needle] == initial_value

    assert_raises(RuntimeError, ctx.pop)
示例#7
0
def test_stack_plain_push_pop():
    ctx = Context()

    needle, initial_value = _default_context.items()[0]
    assert ctx[needle] == initial_value

    ctx.push()
    assert ctx[needle] == initial_value
    ctx[needle] = Nothing
    assert ctx[needle] is Nothing

    ctx.pop()
    assert ctx[needle] is not Nothing
    assert ctx[needle] == initial_value

    assert_raises(RuntimeError, ctx.pop)
示例#8
0
def test_default_minimum_stack():
    ctx = Context()
    with pytest.raises(RuntimeError):
        ctx.pop()