Importar apenas um método estático de classe
Eu tenho o seguinte decorador em uma classe base:
class BaseTests(TestCase):
@staticmethod
def check_time(self, fn):
@wraps(fn)
def test_wrapper(*args,**kwargs):
# do checks ...
return test_wrapper
E a seguinte classe herdando de BaseTests:
from path.base_posting import BaseTests
from path.base_posting.BaseTests import check_time # THIS LINE DOES NOT WORK!
class SpecificTest(BaseTests):
@check_time # use the decorator
def test_post(self):
# do testing ...
Eu gostaria de usar o decorador em SpecificTest como acima, sem ter que usar BaseTests.check_time, porque no código original eles têm nomes longos, e eu tenho que usá-lo em muitos lugares. Alguma ideia?
EDIT: Eu decidi fazer check_time uma função independente no arquivo BaseTests e simplesmente importar
from path.base_posting import BaseTests, check_time