Importar solo un método estático de clase
Tengo el siguiente decorador en una clase base:
class BaseTests(TestCase):
@staticmethod
def check_time(self, fn):
@wraps(fn)
def test_wrapper(*args,**kwargs):
# do checks ...
return test_wrapper
Y la siguiente clase heredada 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 ...
Me gustaría usar el decorador en SpecificTest como antes, sin tener que usar BaseTests.check_time, porque en el código original tienen nombres largos, y tengo que usarlo en muchos lugares. ¿Algunas ideas?
EDITAR: decidí hacer check_time una función independiente en el archivo BaseTests, y simplemente importar
from path.base_posting import BaseTests, check_time