Prohibit addition of new methods to a Python child class
问题 I have two classes that are supposed to implement the same test cases for two independent libraries (let's call them LibA and LibB ). So far I define the test methods to be implemented in an abstract base class which ensures that both test classes implement all desired tests: from abc import ABC, abstractmethod class MyTests(ABC): @abstractmethod def test_foo(self): pass class TestsA(MyTests): def test_foo(self): pass class TestsB(MyTests): def test_foo(self): pass This works as expected, but