예제 #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 _context(self, overrides=()):
     context = Context()
     context.push()
     context.update(self.base_context)
     context.update(overrides)
     return context
예제 #9
0
 def _context(self, overrides=()):
     context = Context()
     context.push()
     context.update(self.base_context)
     context.update(overrides)
     return context