def testNonPackage(self): #{{{
     '''Passing a non-package path returns None'''
     f = op.abspath(__file__)
     name = op.basename(f).split('.')[0]
     d = op.dirname(f)
     path = op.join(d, name)
     self.assertTrue(not absmodpath(path))
 def testNonPythonFile(self): #{{{
     '''Passing a valid but non-python file returns None'''
     f = op.abspath(__file__)
     name = op.basename(f).split('.')[0]
     d = op.dirname(f)
     path = op.join(d, name, 'file')
     self.assertTrue(not absmodpath(path))
 def testInit(self): #{{{
     '''Passing in path to __init__.py[co]? does the right thing'''
     import smanstal.types.module as mod
     me = op.abspath(mod.__file__)
     dir = op.dirname(me)
     init = tuple(op.join(dir, '__init__.py%s' %c) for c in ('', 'c', 'o'))
     expected = 'smanstal.types'
     self.assertTrue(False not in (absmodpath(i) == expected for i in init))
def _atn_gen(suite, regex, filenames): #{{{
    if not isinstance(regex, _REType):
        raise TypeError("%s object is not a compiled regular expression" %regex.__class__.__name__)
    topdir = suite
    if ispackage(suite):
        topdir = op.dirname(suite.__file__)
    for dir, subdir, files in os.walk(topdir):
        for f in files:
            name, ext = op.splitext(f)
            if ext == '.py' and regex.match(name):
                path = op.join(topdir, f)
                yield path if filenames else absmodpath(path)
        for d in subdir:
            path = op.join(topdir, d)
            if hasinit(path) and regex.match(d):
                yield path if filenames else absmodpath(path)
        break
 def testPythonPackage(self): #{{{
     '''Passing a python package'''
     f = op.abspath(__file__)
     d = op.dirname(f)
     expected = 'unit.TestMod_types.TestMod_module'
     self.assertEqual(absmodpath(d), expected)
 def testPythonFile(self): #{{{
     '''Passing a python file'''
     f = op.abspath(__file__)
     expected = 'unit.TestMod_types.TestMod_module.TestFunc_absmodpath'
     self.assertEqual(absmodpath(f), expected)
 def testDynamicModule(self): #{{{
     '''Dynamically creating a module object returns that objects name'''
     import new
     m = new.module('blublah')
     self.assertEqual(absmodpath(m), 'blublah')