Commit 0aed4fe0 authored by Jason Madden's avatar Jason Madden

First part of fixing #1349: Allow test.support.is_resource_enabled to do its...

First part of fixing #1349: Allow test.support.is_resource_enabled to do its usual thing in monkey-patched tests (and eventually our own tests).

By default, this will always return true, so nothing will be skipped. An eventual step is to add options to the testrunner to control which resources are available, analogous to what test.regrtest can do.

Because we always spawn fresh subprocesses, we'll have to do this with environment variables and be sure we have the right setup code always invoked.
parent b5e9c638
......@@ -83,7 +83,6 @@ def _parse_environ(key):
'Please set it to 1, 0 or an empty string' % (key, value))
IGNORE_CFFI = _parse_environ("GEVENT_NO_CFFI_BUILD")
SKIP_LIBUV = _parse_environ('GEVENT_NO_LIBUV_BUILD')
def _get_config_value(key, defkey, path=None):
"""
......
......@@ -18,7 +18,6 @@ from _setuputils import read_version
from _setuputils import system
from _setuputils import PYPY, WIN
from _setuputils import IGNORE_CFFI
from _setuputils import SKIP_LIBUV
from _setuputils import ConfiguringBuildExt
from _setuputils import GeventClean
from _setuputils import BuildFailed
......@@ -193,10 +192,7 @@ if not WIN:
LIBEV_CFFI_MODULE
)
if not SKIP_LIBUV:
# libuv can't be built on manylinux1 because it needs glibc >= 2.12
# but manylinux1 has only 2.5, so we set SKIP_LIBUV in the script make-manylinux
cffi_modules.append(LIBUV_CFFI_MODULE)
cffi_modules.append(LIBUV_CFFI_MODULE)
greenlet_requires = [
# We need to watch our greenlet version fairly carefully,
......
......@@ -21,12 +21,7 @@ monkey.patch_all(**kwargs)
from .sysinfo import RUNNING_ON_APPVEYOR
from .sysinfo import PY37
from .patched_tests_setup import disable_tests_in_source
try:
from test import support
except ImportError:
from test import test_support as support
support.is_resource_enabled = lambda *args: True
del support.use_resources
if RUNNING_ON_APPVEYOR and PY37:
# 3.7 added a stricter mode for thread cleanup.
# It appears to be unstable on Windows (at least appveyor)
......
......@@ -17,22 +17,72 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""
A re-export of the support module from Python's test package, with some
version compatibility shims and overrides.
"""
# A re-export of the support module from Python's test package, with some
# compatibility shims.
# Note that this imports a lot of modules.
import sys
# pylint:disable=wildcard-import,unused-wildcard-import
# Proxy through, so that changes to this module reflect in the
# real module too. In 3.7, this is natively supported.
try:
# Renamed from test_support in Python 3,
# *and* in 2.7.14 (but with a BWC module)
from test.support import *
except ImportError:
from test.test_support import *
class _Default(object):
# A descriptor-like object that will
# only be used if the actual stdlib module
# doesn't have the value.
try:
HOSTv6
except NameError:
HOSTv6 = '::1'
def __init__(self, value):
self.value = value
class _ModuleProxy(object):
__slots__ = ('_orig_mod', '_stdlib_support')
def __init__(self):
self._orig_mod = sys.modules[__name__]
self._stdlib_support = None
def __get_stdlib_support(self):
if self._stdlib_support is None:
try:
# Renamed from test_support in Python 3,
# *and* in 2.7.14 (but with a BWC module)
from test import support as stdlib_support
except ImportError:
from test import test_support as stdlib_support
self._stdlib_support = stdlib_support
return self._stdlib_support
def __getattr__(self, name):
try:
local_val = getattr(self._orig_mod, name)
except AttributeError:
return getattr(self.__get_stdlib_support(), name)
if isinstance(local_val, _Default):
try:
return getattr(self.__get_stdlib_support(), name)
except AttributeError:
return local_val.value
return local_val
def __setattr__(self, name, value):
if name in _ModuleProxy.__slots__:
super(_ModuleProxy, self).__setattr__(name, value)
return
# Setting it deletes it from this module, so that
# we then continue to fall through to the original module.
try:
delattr(self._orig_mod, name)
except AttributeError:
pass
setattr(self.__get_stdlib_support(), name, value)
# When is this not defined in test.support?
HOSTv6 = _Default('::1')
sys.modules[__name__] = _ModuleProxy()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment