pyt/path.py
def set_possible(self):
        '''
        break up a module path to its various parts (prefix, module, class, method)

        this uses PEP 8 conventions, so foo.Bar would be foo module with class Bar

        return -- list -- a list of possible interpretations of the module path
            (eg, foo.bar can be bar module in foo module, or bar method in foo module)
        '''
        possible = []
        name = self.name
        logger.debug('Guessing test name: {}'.format(name))

        name_f = self.name.lower()
        filepath = ""
        if name_f.endswith(".py") or ".py:" in name_f:
            # path/something:Class.method
            bits = name.split(":", 1)
            filepath = bits[0]
            logger.debug('Found filepath: {}'.format(filepath))

            name = bits[1] if len(bits) > 1 else ""
            if name:
                logger.debug('Found test name: {} for filepath: {}'.format(name, filepath))

        bits = name.split('.')
        basedir = self.basedir
        method_prefix = self.method_prefix

        # check if the last bit is a Class
        if re.search(r'^\*?[A-Z]', bits[-1]):
            logger.debug('Found class in name: {}'.format(bits[-1]))
            possible.append(PathFinder(basedir, method_prefix, **{
                'class_name': bits[-1],
                'module_name': bits[-2] if len(bits) > 1 else '',
                'prefix': os.sep.join(bits[0:-2]),
                'filepath': filepath,
            }))
        elif len(bits) > 1 and re.search(r'^\*?[A-Z]', bits[-2]):
            logger.debug('Found class in name: {}'.format(bits[-2]))
            possible.append(PathFinder(basedir, method_prefix, **{
                'class_name': bits[-2],
                'method_name': bits[-1],
                'module_name': bits[-3] if len(bits) > 2 else '',
                'prefix': os.sep.join(bits[0:-3]),
                'filepath': filepath,
            }))
        else:
            if self.name:
                if filepath:
                    if len(bits):
                        possible.append(PathFinder(basedir, method_prefix, **{
                            'filepath': filepath,
                            'method_name': bits[0],
                        }))
                    else:
                        possible.append(PathFinder(basedir, method_prefix, **{
                            'filepath': filepath,
                        }))

                else:
                    logger.debug('Test name is ambiguous')
                    possible.append(PathFinder(basedir, method_prefix, **{
                        'module_name': bits[-1],
                        'prefix': os.sep.join(bits[0:-1]),
                        'filepath': filepath,
                    }))
                    possible.append(PathFinder(basedir, method_prefix, **{
                        'method_name': bits[-1],
                        'module_name': bits[-2] if len(bits) > 1 else '',
                        'prefix': os.sep.join(bits[0:-2]),
                        'filepath': filepath,
                    }))
                    possible.append(PathFinder(basedir, method_prefix, **{
                        'prefix': os.sep.join(bits),
                        'filepath': filepath,
                    }))

            else:
                possible.append(PathFinder(basedir, method_prefix, filepath=filepath))

        logger.debug("Found {} possible test names".format(len(possible)))
        self.possible = possible
def set_possible(self):
        '''
        break up a module path to its various parts (prefix, module, class, method)

        this uses PEP 8 conventions, so foo.Bar would be foo module with class Bar

        return -- list -- a list of possible interpretations of the module path
            (eg, foo.bar can be bar module in foo module, or bar method in foo module)
        '''
        possible = []
        name = self.name
        logger.debug('Guessing test name: {}'.format(name))

        name_f = self.name.lower()
        filepath = ""
        if name_f.endswith(".py") or ".py:" in name_f:
            # path/something:Class.method
            bits = name.split(":", 1)
            filepath = bits[0]
            logger.debug('Found filepath: {}'.format(filepath))

            name = bits[1] if len(bits) > 1 else ""
            if name:
                logger.debug('Found test name: {} for filepath: {}'.format(name, filepath))

        bits = name.split('.')
        basedir = self.basedir
        method_prefix = self.method_prefix

        # check if the last bit is a Class
        if re.search(r'^\*?[A-Z]', bits[-1]):
            logger.debug('Found class in name: {}'.format(bits[-1]))
            possible.append(PathFinder(basedir, method_prefix, **{
                'class_name': bits[-1],
                'module_name': bits[-2] if len(bits) > 1 else '',
                'prefix': os.sep.join(bits[0:-2]),
                'filepath': filepath,
            }))
        elif len(bits) > 1 and re.search(r'^\*?[A-Z]', bits[-2]):
            logger.debug('Found class in name: {}'.format(bits[-2]))
            possible.append(PathFinder(basedir, method_prefix, **{
                'class_name': bits[-2],
                'method_name': bits[-1],
                'module_name': bits[-3] if len(bits) > 2 else '',
                'prefix': os.sep.join(bits[0:-3]),
                'filepath': filepath,
            }))
        else:
            if self.name:
                if filepath:
                    if len(bits):
                        possible.append(PathFinder(basedir, method_prefix, **{
                            'filepath': filepath,
                            'method_name': bits[0],
                        }))
                    else:
                        possible.append(PathFinder(basedir, method_prefix, **{
                            'filepath': filepath,
                        }))

                else:
                    logger.debug('Test name is ambiguous')
                    possible.append(PathFinder(basedir, method_prefix, **{
                        'module_name': bits[-1],
                        'prefix': os.sep.join(bits[0:-1]),
                        'filepath': filepath,
                    }))
                    possible.append(PathFinder(basedir, method_prefix, **{
                        'method_name': bits[-1],
                        'module_name': bits[-2] if len(bits) > 1 else '',
                        'prefix': os.sep.join(bits[0:-2]),
                        'filepath': filepath,
                    }))
                    possible.append(PathFinder(basedir, method_prefix, **{
                        'prefix': os.sep.join(bits),
                        'filepath': filepath,
                    }))

            else:
                possible.append(PathFinder(basedir, method_prefix, filepath=filepath))

        logger.debug("Found {} possible test names".format(len(possible)))
        self.possible = possible
break up a module path to its various parts (prefix, module, class, method)

        this uses PEP 8 conventions, so foo.Bar would be foo module with class Bar

        return -- list -- a list of possible interpretations of the module path
            (eg, foo.bar can be bar module in foo module, or bar method in foo module)