def test_func_deco_with_wraps_depth(): @func_decorator_with_wraps @func_decorator_with_wraps @func_decorator_with_wraps @func_decorator_with_wraps def test(): return 1 assert test.__closure__ is not None result = stripdeco(obj=test, depth=1) assert result == 1 result = stripdeco(obj=test, depth=2) assert result == 1 result = stripdeco(obj=test, depth=3) assert result == 1 result = stripdeco(obj=test, depth=4) assert result == 1
def test_class_deco_with_wraps_depth(): @ClassDecoratorWithWraps() @ClassDecoratorWithWraps() @ClassDecoratorWithWraps() @ClassDecoratorWithWraps() def test(): return 1 assert test.__closure__ is not None result = stripdeco(obj=test, depth=1) assert result == 1 result = stripdeco(obj=test, depth=2) assert result == 1 result = stripdeco(obj=test, depth=3) assert result == 1 result = stripdeco(obj=test, depth=4) assert result == 1
def test_func_deco_without_wraps(): @func_decorator_without_wraps def test(): pass assert test.__closure__ is not None orig = stripdeco(obj=test) assert orig.__closure__ is None
def test_mixed_class_with_wrap_and_func_without_wrap_depth(): @ClassDecoratorWithWraps() @func_decorator_without_wraps @ClassDecoratorWithWraps() @func_decorator_without_wraps def test(): return 1 assert test.__closure__ is not None result = stripdeco(obj=test, depth=1) assert result == 1 result = stripdeco(obj=test, depth=2) assert result == 1 result = stripdeco(obj=test, depth=3) assert result == 1 result = stripdeco(obj=test, depth=4) assert result == 1
def test_class_deco_with_wraps_depth(): @ClassDecoratorWithWraps() @ClassDecoratorWithWraps() @ClassDecoratorWithWraps() @ClassDecoratorWithWraps() def test(): pass assert test.__closure__ is not None orig = stripdeco(obj=test, depth=1) assert orig.__closure__ is not None orig = stripdeco(obj=test, depth=2) assert orig.__closure__ is not None orig = stripdeco(obj=test, depth=3) assert orig.__closure__ is not None orig = stripdeco(obj=test, depth=4) assert orig.__closure__ is None
def test_mixed_class_with_wrap_and_func_without_wrap_depth(): @ClassDecoratorWithWraps() @func_decorator_without_wraps @ClassDecoratorWithWraps() @func_decorator_without_wraps def test(): pass assert test.__closure__ is not None orig = stripdeco(obj=test, depth=1) assert orig.__closure__ is not None orig = stripdeco(obj=test, depth=2) assert orig.__closure__ is not None orig = stripdeco(obj=test, depth=3) assert orig.__closure__ is not None orig = stripdeco(obj=test, depth=4) assert orig.__closure__ is None
def test_class_deco_without_wraps(): @ClassDecoratorWithoutWraps() def test(): pass assert test.__closure__ is not None orig = stripdeco(obj=test) assert orig.__closure__ is None
def test_func_deco_with_wraps_depth(): @func_decorator_with_wraps @func_decorator_with_wraps @func_decorator_with_wraps @func_decorator_with_wraps def test(): pass assert test.__closure__ is not None orig = stripdeco(obj=test, depth=1) assert orig.__closure__ is not None orig = stripdeco(obj=test, depth=2) assert orig.__closure__ is not None orig = stripdeco(obj=test, depth=3) assert orig.__closure__ is not None orig = stripdeco(obj=test, depth=4) assert orig.__closure__ is None
def test_class_deco_without_wraps_two_decorator(): @ClassDecoratorWithoutWraps() @ClassDecoratorWithoutWraps() def test(): return 1 assert test.__closure__ is not None result = stripdeco(obj=test) assert result == 1
def test_mixed_class_with_wrap_and_func_with_wrap(): @ClassDecoratorWithWraps() @func_decorator_with_wraps def test(): return 1 assert test.__closure__ is not None result = stripdeco(obj=test) assert result == 1
def test_mixed_class_with_wrap_and_func_with_wrap(): @ClassDecoratorWithWraps() @func_decorator_with_wraps def test(): pass assert test.__closure__ is not None orig = stripdeco(obj=test) assert orig.__closure__ is None
def test_class_stripdeco_class_deco_with_wraps_depth(): class Test: @ClassDecoratorWithWraps() @ClassDecoratorWithWraps() @ClassDecoratorWithWraps() @ClassDecoratorWithWraps() def run(self): return 1 assert Test().run.__closure__ is not None result = stripdeco(obj=Test().run, depth=1) assert result == 1 result = stripdeco(obj=Test().run, depth=2) assert result == 1 result = stripdeco(obj=Test().run, depth=3) assert result == 1 result = stripdeco(obj=Test().run, depth=4) assert result == 1
def test_func_deco_with_without_wraps_two_decorator(): @func_decorator_without_wraps @func_decorator_without_wraps def test(): return 1 assert test.__closure__ is not None result = stripdeco(obj=test) assert result == 1
def test_class_deco_without_wraps(): class Test: @ClassDecoratorWithoutWraps() def run(self): return 1 assert Test().run.__closure__ is not None orig = stripdeco(obj=Test().run) assert orig == 1
def test_class_deco_with_wraps_two_decorator(): class Test: @ClassDecoratorWithWraps() @ClassDecoratorWithWraps() def run(self): return 1 assert Test().run.__closure__ is not None result = stripdeco(obj=Test().run) assert result == 1
def test_class_has_init_function_deco_with_wraps_depth(): class Test: def __init__(self, user_id): self.user_id = user_id @func_decorator_with_wraps def run(self): return self.user_id user_id = 1 assert Test(user_id=user_id).run.__closure__ is not None orig = stripdeco(obj=Test(user_id=user_id).run, depth=1) assert orig == user_id
def test_class_has_init_class_deco_without_wraps_depth(): class Test: def __init__(self, user_id): self.user_id = user_id @ClassDecoratorWithoutWraps() def run(self): return self.user_id user_id = 1 assert Test(user_id=user_id).run.__closure__ is not None orig = stripdeco(obj=Test(user_id=user_id).run, depth=1) assert orig == user_id
def test_class_has_init_run_and_argument_after_strip_function_deco_without_wraps_depth( ): class Test: def __init__(self, user_id): self.user_id = user_id @func_decorator_without_wraps def run(self, user_pw): return f"{self.user_id}{user_pw}" user_id = 1 user_pw = 2 assert Test(user_id=user_id).run.__closure__ is not None orig = stripdeco( obj=Test(user_id=user_id).run, user_pw=user_pw, depth=1, ) assert orig == f"{user_id}{user_pw}"