Esempio n. 1
0
def prepare_stdlib_test(filename):
    patch_all(timeout=20)
    import test
    try:
        if sys.version_info[0] >= 3:
            from test import support as test_support
        else:
            from test import test_support
    except ImportError:
        sys.stderr.write('test.__file__ = %s\n' % test.__file__)
        raise
    test_support.use_resources = ContainsAll()

    name = os.path.splitext(os.path.basename(filename))[0].replace('_patched', '')

    os.environ['__module_name__'] = name

    try:
        _f, _filename, _ = imp_find_dotted_module('test.%s' % name)
    except:
        if version in missing_modules.get(name, []):
            sys.exit(0)
        sys.stderr.write('Failed to import test.%s\n' % name)
        raise

    module_source = _f.read()
    from patched_tests_setup import disable_tests_in_source
    module_source = disable_tests_in_source(module_source, name)
    module_code = compile(module_source, _filename, 'exec')

    print('Testing %s with monkey patching' % _filename, file=sys.stderr)
    return module_code
Esempio n. 2
0
def prepare_stdlib_test(filename):
    patch_all(timeout=20)
    import test
    try:
        from test import test_support
    except ImportError:
        try:
            from test import support as test_support
        except ImportError:
            sys.stderr.write('test.__file__ = %s\n' % test.__file__)
            raise
    test_support.use_resources = ContainsAll()

    name = os.path.splitext(os.path.basename(filename))[0].replace('_patched', '')

    os.environ['__module_name__'] = name

    try:
        _f, _filename, _ = imp_find_dotted_module('test.%s' % name)
    except:
        if version in missing_modules.get(name, []):
            sys.exit(0)
        sys.stderr.write('Failed to import test.%s\n' % name)
        raise

    module_source = _f.read()
    from patched_tests_setup import disable_tests_in_source
    module_source = disable_tests_in_source(module_source, name)
    module_code = compile(module_source, _filename, 'exec')

    print >> sys.stderr, 'Testing %s with monkey patching' % _filename
    return module_code
Esempio n. 3
0
kwargs = {}

if sys.argv[1] == '--Event':
    kwargs['Event'] = True
    del sys.argv[1]
else:
    kwargs['Event'] = False

test_filename = sys.argv[1]
del sys.argv[1]

print(('Running with patch_all(%s): %s' % (','.join('%s=%r' % x for x in list(kwargs.items())), test_filename)))

from gevent import monkey; monkey.patch_all(**kwargs)

from patched_tests_setup import disable_tests_in_source
import test.test_support
test.test_support.is_resource_enabled = lambda *args: True
del test.test_support.use_resources

if sys.version_info[:2] <= (2, 6):
    test.test_support.TESTFN += '_%s' % os.getpid()

__file__ = os.path.join(os.getcwd(), test_filename)

test_name = os.path.splitext(test_filename)[0]
module_source = open(test_filename).read()
module_source = disable_tests_in_source(module_source, test_name)
module_code = compile(module_source, test_filename, 'exec')
exec (module_code in globals())
Esempio n. 4
0
if sys.argv[1] == '--Event':
    kwargs['Event'] = True
    del sys.argv[1]
else:
    kwargs['Event'] = False

test_filename = sys.argv[1]
del sys.argv[1]

print 'Running with patch_all(%s): %s' % (','.join(
    '%s=%r' % x for x in kwargs.items()), test_filename)

from gevent import monkey
monkey.patch_all(**kwargs)

from patched_tests_setup import disable_tests_in_source
import test.test_support
test.test_support.is_resource_enabled = lambda *args: True
del test.test_support.use_resources

if sys.version_info[:2] <= (2, 6):
    test.test_support.TESTFN += '_%s' % os.getpid()

__file__ = os.path.join(os.getcwd(), test_filename)

test_name = os.path.splitext(test_filename)[0]
module_source = open(test_filename).read()
module_source = disable_tests_in_source(module_source, test_name)
module_code = compile(module_source, test_filename, 'exec')
exec module_code in globals()