I'm new to bitcoin coming from a Python background. Wrapping my head around your test suite, I noticed that the base framework test class makes comments about how subclasses should override set_test_params and run_test but should not override __init__ or main:
To make that more explicit, have we considered a meta class to actually check that those assumptions are valid instead of leaving it to the user to read the docstring and follow the rules?
I've provided a sample implementation in the details below, where the commented methods would raise an error if included in any module. Happy to submit a PR if you think it is worth pursuing.
<details>
class BitcoinTestMetaclass(type):
def __new__(cls, clsname, bases, dct):
if not ('run_test' in dct and 'set_test_params' in dct):
raise TypeError("BitcoinTestFramework subclasses must override "
"'run_test' and 'set_test_params'")
if '__init__' in dct or 'main' in dct:
raise TypeError("BitcoinTestFramework subclasses may not override "
"'__init__' or 'main'")
return super().__new__(cls, clsname, bases, dct)
class BitcoinTestFramework(metaclass=BitcoinTestMetaclass):
def set_test_params(self):
...
def run_test(self):
...
'''
class BadSubclass1(BitcoinTestFramework):
"""Doesn't subclass run_test"""
def set_test_params(self):
pass
'''
'''
class BadSubclass2(BitcoinTestFramework):
"""Overrides set_test_params and run_test, but also overrides __init__"""
def __init__(self):
super().__init__()
def set_test_params(self):
pass
def run_test(self):
pass
'''
class GoodSubclass(BitcoinTestFramework):
def set_test_params(self):
pass
def run_test(self):
pass