Пример #1
0
 def is_regex(thing):
     return hasattr(thing, 'pattern') and hasmethod(thing, 'search')
Пример #2
0
 def is_regex(thing):
     return hasattr(thing, "pattern") and hasmethod(thing, "search")
Пример #3
0
 def test_hasmethod_property_method(self):
     """
     hasmethod returns False for an @property method.
     """
     assert_false(hasmethod(self.an_object, 'a_property_method'))
Пример #4
0
 def test_hasmethod_class_method(self):
     """
     hasmethod returns True for a callable class method.
     """
     assert_true(hasmethod(self.an_object, 'a_class_method'))
Пример #5
0
 def test_hasmethod_method(self):
     """
     hasmethod returns True for a callable instance method.
     """
     assert_true(hasmethod(self.an_object, 'a_method'))
Пример #6
0
 def test_hasmethod_class_property(self):
     """
     hasmethod returns False for a non-callable class property.
     """
     assert_false(hasmethod(self.an_object, 'a_class_property'))
Пример #7
0
 def test_hasmethod_invalid_attr(self):
     """
     hasmethod returns False for an invalid attribute.
     """
     assert_false(hasmethod(self.an_object, 'invalid'))