From c2279e3d80d722867a38863116a7ee2c4e1b4c55 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Mon, 25 May 2020 01:26:14 -0700 Subject: [PATCH] teststubtest: add a test for the previous commit Also covers some of the MRO logic in verify_typeinfo --- mypy/test/teststubtest.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mypy/test/teststubtest.py b/mypy/test/teststubtest.py index 34be30d43627e..fe7c67261ded6 100644 --- a/mypy/test/teststubtest.py +++ b/mypy/test/teststubtest.py @@ -588,6 +588,38 @@ def __mangle_bad(self, text): pass error="X.__mangle_bad" ) + @collect_cases + def test_mro(self) -> Iterator[Case]: + yield Case( + stub=""" + class A: + def foo(self, x: int) -> None: ... + class B(A): + pass + class C(A): + pass + """, + runtime=""" + class A: + def foo(self, x: int) -> None: ... + class B(A): + def foo(self, x: int) -> None: ... + class C(A): + def foo(self, y: int) -> None: ... + """, + error="C.foo" + ) + yield Case( + stub=""" + class X: ... + """, + runtime=""" + class X: + def __init__(self, x): pass + """, + error="X.__init__" + ) + def remove_color_code(s: str) -> str: return re.sub("\\x1b.*?m", "", s) # this works!