2
4
# By default, test cases are expected to switch and emit warnings if there was none
3
5
# If a test is found in this list, it's expected not to switch.
4
switch_not_expected = '''test_select.SelectTestCase.test_error_conditions
6
tests = '''test_select.SelectTestCase.test_error_conditions
5
7
test_ftplib.TestFTPClass.test_all_errors
6
8
test_ftplib.TestFTPClass.test_getwelcome
7
9
test_ftplib.TestFTPClass.test_sanitize
8
10
test_ftplib.TestFTPClass.test_set_pasv
9
test_ftplib.TestIPv6Environment.test_af'''.split()
11
test_ftplib.TestIPv6Environment.test_af
12
test_socket.TestExceptions.testExceptionTree
13
test_socket.Urllib2FileobjectTest.testClose
14
test_socket.TestLinuxAbstractNamespace.testLinuxAbstractNamespace
15
test_socket.TestLinuxAbstractNamespace.testMaxName
16
test_socket.TestLinuxAbstractNamespace.testNameOverflow
17
test_socket.GeneralModuleTests.*
20
tests = [x.strip().replace('\.', '\\.').replace('*', '.*?') for x in tests.split('\n') if x.strip()]
21
tests = re.compile('^%s$' % '|'.join(tests))
24
def get_switch_expected(fullname):
26
>>> get_switch_expected('test_select.SelectTestCase.test_error_conditions')
28
>>> get_switch_expected('test_socket.GeneralModuleTests.testCrucialConstants')
30
>>> get_switch_expected('test_socket.SomeOtherTest.testHello')
33
if tests.match(fullname) is not None:
12
40
# uses signal module which does not work with gevent (use gevent.signal())
15
43
# uses some internal C API of threads not available when threads are emulated with greenlets
16
44
'test_threading.ThreadTests.test_PyThreadState_SetAsyncExc',
18
# this one is a bogus test that fails even without monkey patching
19
'test_threading.ThreadTests.test_foreign_thread',
21
46
# access _sock.gettimeout() which is always in non-blocking mode
22
47
'test_urllib2net.TimeoutTest.test_ftp_no_timeout',
23
48
'test_urllib2net.TimeoutTest.test_ftp_timeout',
27
52
# this test seems to have a bug which makes it fail with error: (107, 'Transport endpoint is not connected')
28
53
# (they create TCP socket, not UDP)
29
'test_socket.UDPTimeoutTest.testUDPTimeout'
54
'test_socket.UDPTimeoutTest.testUDPTimeout']
56
if sys.version_info[:2] < (2, 7):
57
# On Python 2.6, this test fails even without monkey patching
58
disabled_tests.append('test_threading.ThreadTests.test_foreign_thread')
34
61
def disable_tests_in_the_source(source, name):
35
62
my_disabled_tests = [x for x in disabled_tests if x.startswith(name + '.')]
41
68
source, n = re.subn(testcase, 'XXX' + testcase, source)
42
69
print >> sys.stderr, 'Removed %s (%d)' % (testcase, n)