code: 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)
  
imports: import os
  from contextlib import contextmanager
label_desc: Use image node_id 2 for calling a global function with example usage: monkeypatch(obj, attribute_name, new_value) without return types