Пример #1
0
    def testModule(self, m, name=''):
        # check that __all__ names exist in module m
        self.subtitle(m, 'Module')

        m_ = (name or m.__name__).split('.')[-1] + '.'
        for a in sorted(m.__all__):
            n = m_ + a + type2str(m, a)
            o = getattr(m, a, None)
            t = getattr(o, '__module__', None)
            if t and t != m.__name__:
                n = '%s (%s)' % (n, t)
            self.test(n, hasattr(m, a), True)
Пример #2
0
 def testAttrs(self, classname, modules, *args, **kwds):
     self._subtitle(classname, 'Attrs', modules)
     attrs = {}
     for m in modules:
         C = getattr(m, classname, None)
         if C:
             i = C(*args, **kwds)
             n = basename(m.__name__)
             for a in dir(i):
                 if not a.startswith('_'):
                     a += type2str(C, a)
                     attrs[a] = attrs.get(a, ()) + (n, )
     for a, m in sorted(attrs.items()):
         m = ', '.join(sorted(m))
         self.test(a, m, m)  # passes always
Пример #3
0
    def testLazily(self):

        z = lazily.isLazy
        self.test('isLazy', z, z)
        if not z:
            for a, m in lazily._all_missing2(_all_):
                self.test('missing in %s' % (a, ), m or None, None)

        # simple lazy_import enable tests
        self.test('cmd', _cmd, _cmd)
        if _env_cmd:
            for z in range(5):
                e = 'PYGEODESY_LAZY_IMPORT=%s' % (z, )
                c = _env_cmd % (e, z if isPython37 else None)
                self.test(e, os.system(c), 0)
        else:
            self.skip('no _env_cmd')

        for a in sorted(_all_, key=str.lower):
            t = type2str(pygeodesy, a).replace('()', '').strip()
            self.test(a, t, t)
Пример #4
0
            t = getattr(o, '__module__', None)
            if t and t != m.__name__:
                n = '%s (%s)' % (n, t)
            self.test(n, hasattr(m, a), True)


if __name__ == '__main__':

    import pygeodesy  # PYCHOK expected
    from inspect import ismodule

    t = Tests(__file__, __version__)

    t.testModule(pygeodesy, 'pygeodesy')
    for a in sorted(pygeodesy.__all__):
        m = getattr(pygeodesy, a)
        if ismodule(m):
            t.testModule(m)

    # check module for public functions, etc.
    t.subtitle(pygeodesy, 'Public')
    for a in sorted(pygeodesy.__all__):
        f = getattr(pygeodesy, a)
        m = getattr(f, '__module__', '.').split('.')[-1]
        if m and m not in ('bases', 'math'):
            n = a + type2str(pygeodesy, a)
            t.test(n, m in pygeodesy.__all__, True)

    t.results()
    t.exit()