Beispiel #1
0
    def find_single_method(self, name):
        chains = sorted(self._find_method_chains(name), key=lambda t: len(t))
        result = []

        for i in range(len(chains)):
            if chains[i][0] in result:
                continue
            add = True
            for j in range(i + 1, len(chains)):
                common = 0
                if not add:
                    break
                for p in range(len(chains[i])):
                    if chains[i][-p - 1] is chains[j][-p - 1]:
                        common += 1
                    else:
                        break
                if common == len(chains[i]):
                    add = False
                    break
            if add:
                result.append(chains[i][0])
        if len(result) < 1:
            raise exceptions.NoMethodFound(name)
        elif len(result) > 1:
            raise exceptions.AmbiguousMethodName(name)
        return result[0]
Beispiel #2
0
 def find_single_method(self, name):
     result = self.find_method(name)
     if len(result) < 1:
         raise exceptions.NoMethodFound(name)
     elif len(result) > 1:
         raise exceptions.AmbiguousMethodName(name)
     return result[0]
 def find_single_method(name):
     if name != 'mockHandler':
         raise exceptions.NoMethodFound(name)