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
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]
def _context(self, overrides=()): context = Context() context.push() context.update(self.base_context) context.update(overrides) return context
def test_update_bogus(): ctx = Context() with pytest.raises(TypeError): ctx.update([], [])