예제 #1
0
def test_update_unknown():
    ctx = Context()
    assert u'xyzzy' not in _default_context.keys()

    with pytest.raises(KeyError):

        ctx.update(xyzzy=123)
    assert u'xyzzy' not in ctx
예제 #2
0
def test_update_known():
    ctx = Context()
    known = _default_context.keys()
    sentinels = [object(), object()]

    iterable = [(known[0], sentinels[0])]
    kwargs = {known[1].encode('ascii'): sentinels[1]}

    ctx.update(iterable, **kwargs)

    assert ctx[known[0]] is sentinels[0]
    assert ctx[known[1]] is sentinels[1]

    ctx = Context()
    ctx.update(iterable)
    assert ctx[known[0]] is sentinels[0]

    ctx = Context()
    ctx.update(**kwargs)
    assert ctx[known[1]] is sentinels[1]
예제 #3
0
def test_update_known():
    ctx = Context()
    known = _default_context.keys()
    sentinels = [object(), object()]

    iterable = [(known[0], sentinels[0])]
    kwargs = {known[1].encode('ascii'): sentinels[1]}

    ctx.update(iterable, **kwargs)

    assert ctx[known[0]] is sentinels[0]
    assert ctx[known[1]] is sentinels[1]

    ctx = Context()
    ctx.update(iterable)
    assert ctx[known[0]] is sentinels[0]

    ctx = Context()
    ctx.update(**kwargs)
    assert ctx[known[1]] is sentinels[1]
예제 #4
0
 def _context(self, overrides=()):
     context = Context()
     context.push()
     context.update(self.base_context)
     context.update(overrides)
     return context
예제 #5
0
 def _context(self, overrides=()):
     context = Context()
     context.push()
     context.update(self.base_context)
     context.update(overrides)
     return context
예제 #6
0
def test_update_bogus():
    ctx = Context()
    with pytest.raises(TypeError):
        ctx.update([], [])