Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
gevent / src / gevent / tests / test__execmodules.py
Size: Mime:
import unittest
import warnings

from gevent.testing import modules
from gevent.testing import main
from gevent.testing.sysinfo import NON_APPLICABLE_SUFFIXES
from gevent.testing import six


def make_exec_test(path, module):

    def test(_):
        with open(path, 'rb') as f:
            src = f.read()
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', DeprecationWarning)
            try:
                six.exec_(src, {'__file__': path})
            except ImportError:
                if module in modules.OPTIONAL_MODULES:
                    raise unittest.SkipTest("Unable to import optional module %s" % module)
                raise

    name = "test_" + module.replace(".", "_")
    test.__name__ = name
    return test

def make_all_tests(cls):
    for path, module in modules.walk_modules(recursive=True, check_optional=False):
        if module.endswith(NON_APPLICABLE_SUFFIXES):
            continue
        test = make_exec_test(path, module)
        setattr(cls, test.__name__, test)
    return cls


@make_all_tests
class Test(unittest.TestCase):
    pass


if __name__ == '__main__':
    main()