parameters: (obj, attribute_name, new_value)
docstring: Like pytest's monkeypatch, but as a context manager.
docstring_summary: Like pytest's monkeypatch, but as a context manager.
docstring_tokens: Like pytest s monkeypatch but as a context manager .
function: def monkeypatch(obj, attribute_name, new_value):
      """
      Like pytest's monkeypatch, but as a context manager.
      """
      old_value = getattr(obj, attribute_name)
      try:
          setattr(obj, attribute_name, new_value)
          yield
      finally:
          setattr(obj, attribute_name, old_value)
function_tokens: def monkeypatch ( obj , attribute_name , new_value ) : old_value = getattr ( obj , attribute_name ) try : setattr ( obj , attribute_name , new_value ) yield finally : setattr ( obj , attribute_name , old_value )