I have base test case class which sub-classes supposed to be decorated with flaky decorator (https://github.com/box/flaky), in other words I want to apply flaky decorator to every test case (test methods) but do it from a base class, use single place instead of decorating every test class or test case (there are plenty of test cases...).
But if I apply decorator to base class CustomTestCase it will affect every method (include helper methods, constructors, etc). Is it possible to apply it to test cases only (methods starts with 'test') from base class. I've tried to do it by accessing self._testMethod in CustomTestCase.setUp without success.
# base class
@flaky(max_runs=3, min_passes=1)
class CustomTestCase(SimpleTestCase):
"""
base class for tests using Selenium.
"""
@classmethod
def setUpClass(cls):
pass
def setUp(self):
pass
# child class - test suite
class TestSomething(CustomTestCase):
"""
This class contains all different tests
"""
def test_something(self):
""" should be decorated by flaky """
self.assertEqual(1, randint(0, 1))
def test_another(self):
self.assertEqual(1, randint(0, 1))