I have a run_once decorator from : Efficient way of having a function only execute once in a loop A parent class like:
class Parent:
    @run_once
    def test(self,x):
        print(x)
    def call_test(self,):
        for x in [1,3,4]:
            self.test(x)
Class Child1(Parent):
    def child_method(self,): 
        self.call_test()
Class Child2(Parent):
    def child_method(self,): 
        self.call_test()
Now When I use pytest to test the both child classes
def test_child1():
    c1 = Child1()
    c1.child_method()
    # assert that x is printed once
    # tried to reset `test.has_run` = False # didn't work
    # throws: *** AttributeError: 'method' object has no attribute 'has_run'
def test_child2():
    c2 = Child2()
    c2.child_method()
    # assert that x is printed once # FAILS because the test.has_run is already set in `c1.child_method()` call.
Is there a way to make run_once on object level ?