Code | Explanation |
---|---|
from contextlib import nullcontext |
Import the nullcontext context manager from the contextlib module. |
monkeypatch.setattr(schema_patcher, "handle_patching", lambda _: nullcontext()) |
Replace the handle_patching function with a lambda function that returns a nullcontext object. |
with push_and_pop_path(MODULE_PATH): schema_patcher.patch_schema(iglu) |
Call the patch_schema function within a with statement that uses the push_and_pop_path context manager. |
Created
July 17, 2023 03:55
-
-
Save pkutaj/16e94be79b89f67d14d906d4a59405bd to your computer and use it in GitHub Desktop.
2023-07-17-How-to-Create-Dummy-Context-Manager-for-Python-Unit-Tests.md
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment