Completed
Pull Request — master (#75)
by Cézar
01:32
created

hasmethod()   A

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
1
__author__ = "Jon Reid"
2
__copyright__ = "Copyright 2011 hamcrest.org"
3
__license__ = "BSD, see License.txt"
4
5
6
def hasmethod(obj, methodname):
7
    """Does ``obj`` have a method named ``methodname``?"""
8
9
    if not hasattr(obj, methodname):
10
        return False
11
    method = getattr(obj, methodname)
12
    return callable(method)
13