def testRaisesWithNonCallableObject(self):
     with self.assertRaises(ValueError):
         function_utils.get_func_code(None)
 def testWithLambda(self):
     anon_fn = lambda x: x
     code = function_utils.get_func_code(anon_fn)
     self.assertIsNotNone(code)
     self.assertRegex(code.co_filename, 'function_utils_test.py')
 def testWithFunctoolsPartial(self):
     partial = functools.partial(silly_example_function)
     code = function_utils.get_func_code(partial)
     self.assertIsNone(code)
 def testWithClassMethod(self):
     code = function_utils.get_func_code(self.testWithClassMethod)
     self.assertIsNotNone(code)
     self.assertRegex(code.co_filename, 'function_utils_test.py')
 def testWithCallableClass(self):
     callable_instance = SillyCallableClass()
     code = function_utils.get_func_code(callable_instance)
     self.assertIsNotNone(code)
     self.assertRegex(code.co_filename, 'function_utils_test.py')
 def testRaisesWithNonCallableObject(self):
   with self.assertRaises(ValueError):
     function_utils.get_func_code(None)
 def testWithSimpleFunction(self):
     code = function_utils.get_func_code(silly_example_function)
     self.assertIsNotNone(code)
     self.assertRegex(code.co_filename, 'function_utils_test.py')
 def testWithFunctoolsPartial(self):
   partial = functools.partial(silly_example_function)
   code = function_utils.get_func_code(partial)
   self.assertIsNone(code)
 def testWithLambda(self):
   anon_fn = lambda x: x
   code = function_utils.get_func_code(anon_fn)
   self.assertIsNotNone(code)
   self.assertRegexpMatches(code.co_filename, 'function_utils_test.py')
 def testWithCallableClass(self):
   callable_instance = SillyCallableClass()
   code = function_utils.get_func_code(callable_instance)
   self.assertIsNotNone(code)
   self.assertRegexpMatches(code.co_filename, 'function_utils_test.py')
 def testWithClassMethod(self):
   code = function_utils.get_func_code(self.testWithClassMethod)
   self.assertIsNotNone(code)
   self.assertRegexpMatches(code.co_filename, 'function_utils_test.py')
 def testWithSimpleFunction(self):
   code = function_utils.get_func_code(silly_example_function)
   self.assertIsNotNone(code)
   self.assertRegexpMatches(code.co_filename, 'function_utils_test.py')