summaryrefslogtreecommitdiff
path: root/tests/testdata/python3/data/metaclass_recursion/monkeypatch.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testdata/python3/data/metaclass_recursion/monkeypatch.py')
-rw-r--r--tests/testdata/python3/data/metaclass_recursion/monkeypatch.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/testdata/python3/data/metaclass_recursion/monkeypatch.py b/tests/testdata/python3/data/metaclass_recursion/monkeypatch.py
new file mode 100644
index 00000000..757bb3f8
--- /dev/null
+++ b/tests/testdata/python3/data/metaclass_recursion/monkeypatch.py
@@ -0,0 +1,17 @@
+# https://github.com/PyCQA/astroid/issues/749
+# Not an actual module but allows us to reproduce the issue
+from tests.testdata.python3.data.metaclass_recursion import parent
+
+class MonkeyPatchClass(parent.OriginalClass):
+ _original_class = parent.OriginalClass
+
+ @classmethod
+ def patch(cls):
+ if parent.OriginalClass != MonkeyPatchClass:
+ cls._original_class = parent.OriginalClass
+ parent.OriginalClass = MonkeyPatchClass
+
+ @classmethod
+ def unpatch(cls):
+ if parent.OriginalClass == MonkeyPatchClass:
+ parent.OriginalClass = cls._original_class