def test_getmethodclass_weakref_mechanism(self): test_obj = TestClass() def test_fn(self): return self bound_method = types.MethodType( test_fn, function.TfMethodTarget(weakref.ref(test_obj), test_obj.member_function)) self.assertEqual(inspect_utils.getmethodclass(bound_method), TestClass)
def test_is_allowlisted_tfmethodwrapper(self): class TestClass(object): def member_function(self): pass TestClass.__module__ = 'test_allowlisted_call' test_obj = TestClass() def test_fn(self): del self bound_method = types.MethodType( test_fn, function.TfMethodTarget(weakref.ref(test_obj), test_obj.member_function)) self.assertTrue(conversion.is_allowlisted(bound_method))