def test_is_function_instance_method(self): class Foo(object): def method(self): pass @staticmethod def staticmethod(): pass @classmethod def classmethod(cls): pass f = Foo() self.assertTrue(is_function(f.method)) self.assertTrue(is_function(f.staticmethod)) self.assertTrue(is_function(f.classmethod))
def test_is_function_instance_method(self): class Foo(object): def method(self): pass @staticmethod def staticmethod(): pass @classmethod def classmethod(cls): pass f = Foo() self.assertTrue(util.is_function(f.method)) self.assertTrue(util.is_function(f.staticmethod)) self.assertTrue(util.is_function(f.classmethod))
def get_obj_cls(obj): if not obj or util.is_function(obj): return None if util.is_container(obj): return obj if not util.is_primitive(obj): return type(obj) return None
def _flatten_dict_obj(self, obj, data): """_flatten_dict_obj recursively calls to flatten() on a dictionary's values. and places them into data. """ for k, v in obj.iteritems(): if util.is_function(v): continue if type(k) not in types.StringTypes: k = repr(k) self._namestack.append(k) data[k] = self.flatten(v) self._namestack.pop() return data
def test_is_function_lambda(self): self.assertTrue(is_function(lambda: False))
def test_is_function_builtins(self): self.assertTrue(is_function(globals))
def test_is_function_lambda(self): self.assertTrue(util.is_function(lambda: False))
def test_is_function_builtins(self): self.assertTrue(util.is_function(globals))