Commit e6294197 authored by Jason Madden's avatar Jason Madden

Fix test__execmodules on windows

parent 23c5ee4a
from gevent._fileobjectposix import FileObjectPosix try:
from gevent._fileobjectposix import FileObjectPosix
__all__ = ['FileObjectPosix', ] __all__ = ['FileObjectPosix', ]
except ImportError:
import sys
assert sys.platform.startswith('win'), "Should be able to import except on Windows"
__all__ = []
...@@ -475,7 +475,7 @@ if hasattr(_socket, 'socketpair'): ...@@ -475,7 +475,7 @@ if hasattr(_socket, 'socketpair'):
one._drop() one._drop()
two._drop() two._drop()
return result return result
else: elif 'socketpair' in __implements__:
__implements__.remove('socketpair') __implements__.remove('socketpair')
if hasattr(_socket, 'fromfd'): if hasattr(_socket, 'fromfd'):
...@@ -487,7 +487,7 @@ if hasattr(_socket, 'fromfd'): ...@@ -487,7 +487,7 @@ if hasattr(_socket, 'fromfd'):
s._drop() s._drop()
return result return result
else: elif 'fromfd' in __implements__:
__implements__.remove('fromfd') __implements__.remove('fromfd')
if hasattr(__socket__, 'ssl'): if hasattr(__socket__, 'ssl'):
......
...@@ -48,6 +48,29 @@ else: ...@@ -48,6 +48,29 @@ else:
gettotalrefcount = getattr(sys, 'gettotalrefcount', None) gettotalrefcount = getattr(sys, 'gettotalrefcount', None)
OPTIONAL_MODULES = ['resolver_ares'] OPTIONAL_MODULES = ['resolver_ares']
# Generally, ignore the portions that are only implemented
# on particular platforms; they generally contain partial
# implementations completed in different modules.
PLATFORM_SPECIFIC_SUFFIXES = ['2', '279', '3']
if sys.platform.startswith('win'):
PLATFORM_SPECIFIC_SUFFIXES.append('posix')
NON_APPLICABLE_SUFFIXES = []
if sys.version_info[0] == 3:
# Python 3
NON_APPLICABLE_SUFFIXES.extend(('2', '279'))
if sys.version_info[0] == 2:
# Any python 2
NON_APPLICABLE_SUFFIXES.append('3')
if (sys.version_info[1] < 7
or (sys.version_info[1] == 7 and sys.version_info[2] < 9)):
# Python 2, < 2.7.9
NON_APPLICABLE_SUFFIXES.append('279')
if sys.platform.startswith('win'):
NON_APPLICABLE_SUFFIXES.append("posix")
# This is intimately tied to FileObjectPosix
NON_APPLICABLE_SUFFIXES.append("fileobject2")
class ExpectedException(Exception): class ExpectedException(Exception):
"""An exception whose traceback should be ignored""" """An exception whose traceback should be ignored"""
......
...@@ -5,6 +5,7 @@ import sys ...@@ -5,6 +5,7 @@ import sys
import unittest import unittest
import types import types
from greentest import walk_modules from greentest import walk_modules
from greentest import PLATFORM_SPECIFIC_SUFFIXES
MAPPING = { MAPPING = {
...@@ -162,13 +163,7 @@ are missing from %r: ...@@ -162,13 +163,7 @@ are missing from %r:
raise AssertionError(msg) raise AssertionError(msg)
def _test(self, modname): def _test(self, modname):
# Generally, ignore the portions that are only implemented for x in PLATFORM_SPECIFIC_SUFFIXES:
# on particular platforms; they generally contain partial
# implementations completed in different modules.
ignored_suffixes = ['2', '279', '3']
if sys.platform.startswith('win'):
ignored_suffixes.append('posix')
for x in ignored_suffixes:
if modname.endswith(x): if modname.endswith(x):
return return
......
import sys import sys
from gevent.hub import PYGTE279 from gevent.hub import PYGTE279
from greentest import walk_modules, BaseTestCase, main from greentest import walk_modules, BaseTestCase, main, NON_APPLICABLE_SUFFIXES
import six import six
...@@ -22,12 +22,14 @@ def make_exec_test(path, module): ...@@ -22,12 +22,14 @@ def make_exec_test(path, module):
for path, module in walk_modules(): for path, module in walk_modules():
if sys.version_info[0] == 3 and path.endswith('2.py'): ignored = False
continue for x in NON_APPLICABLE_SUFFIXES:
if sys.version_info[0] == 2 and path.endswith('3.py'): if module.endswith(x):
continue ignored = True
if not PYGTE279 and path.endswith('279.py'): break
if ignored:
continue continue
make_exec_test(path, module) make_exec_test(path, module)
......
...@@ -55,7 +55,6 @@ if sys.platform == 'win32': ...@@ -55,7 +55,6 @@ if sys.platform == 'win32':
# fork watchers don't get called in multithreaded programs on windows # fork watchers don't get called in multithreaded programs on windows
# No idea why. # No idea why.
'test__core_fork.py', 'test__core_fork.py',
'test__execmodules.py',
'FLAKY test__greenletset.py', 'FLAKY test__greenletset.py',
# The various timeout tests are flaky for unknown reasons # The various timeout tests are flaky for unknown reasons
# on appveyor # on appveyor
......
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