~ubuntu-branches/ubuntu/utopic/python-gevent/utopic-proposed

« back to all changes in this revision

Viewing changes to greentest/patched_tests_setup.py

  • Committer: Bazaar Package Importer
  • Author(s): Örjan Persson
  • Date: 2011-05-17 16:43:20 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517164320-844bxblhlra65dml
Tags: 0.13.6-1
New upstream version (Closes: #601863).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import sys
 
2
import re
1
3
 
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.*
 
18
'''
 
19
 
 
20
tests = [x.strip().replace('\.', '\\.').replace('*', '.*?') for x in  tests.split('\n') if x.strip()]
 
21
tests = re.compile('^%s$' % '|'.join(tests))
 
22
 
 
23
 
 
24
def get_switch_expected(fullname):
 
25
    """
 
26
    >>> get_switch_expected('test_select.SelectTestCase.test_error_conditions')
 
27
    False
 
28
    >>> get_switch_expected('test_socket.GeneralModuleTests.testCrucialConstants')
 
29
    False
 
30
    >>> get_switch_expected('test_socket.SomeOtherTest.testHello')
 
31
    True
 
32
    """
 
33
    if tests.match(fullname) is not None:
 
34
        print fullname
 
35
        return False
 
36
    return True
 
37
 
10
38
 
11
39
disabled_tests = [
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',
17
45
 
18
 
    # this one is a bogus test that fails even without monkey patching
19
 
    'test_threading.ThreadTests.test_foreign_thread',
20
 
 
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',
26
51
 
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'
30
 
]
31
 
 
32
 
import sys, re
 
54
    'test_socket.UDPTimeoutTest.testUDPTimeout']
 
55
 
 
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')
 
59
 
33
60
 
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)
43
70
    return source
44