Commit d67b3123 authored by Denis Bilenko's avatar Denis Bilenko

make greentest read 'switch_expected' setting from patched_tests_setup.py

parent 8497ff6f
......@@ -22,12 +22,14 @@
# package is named greentest, not test, so it won't be confused with test in stdlib
import sys
import unittest
from unittest import TestCase as BaseTestCase
import time
import traceback
import re
import os
from os.path import basename, splitext
import gevent
from patched_tests_setup import get_switch_expected
VERBOSE = sys.argv.count('-v') > 1
......@@ -38,12 +40,17 @@ else:
DEBUG = False
class TestCase(unittest.TestCase):
class TestCase(BaseTestCase):
__timeout__ = 1
switch_expected = True
switch_expected = 'default'
_switch_count = None
def run(self, *args, **kwargs):
if self.switch_expected == 'default':
self.switch_expected = get_switch_expected(self.fullname)
return BaseTestCase.run(self, *args, **kwargs)
def setUp(self):
gevent.sleep(0) # switch at least once to setup signal handlers
hub = gevent.hub.get_hub()
......
......@@ -3,12 +3,37 @@ import re
# By default, test cases are expected to switch and emit warnings if there was none
# If a test is found in this list, it's expected not to switch.
switch_not_expected = '''test_select.SelectTestCase.test_error_conditions
tests = '''test_select.SelectTestCase.test_error_conditions
test_ftplib.TestFTPClass.test_all_errors
test_ftplib.TestFTPClass.test_getwelcome
test_ftplib.TestFTPClass.test_sanitize
test_ftplib.TestFTPClass.test_set_pasv
test_ftplib.TestIPv6Environment.test_af'''.split()
test_ftplib.TestIPv6Environment.test_af
test_socket.TestExceptions.testExceptionTree
test_socket.Urllib2FileobjectTest.testClose
test_socket.TestLinuxAbstractNamespace.testLinuxAbstractNamespace
test_socket.TestLinuxAbstractNamespace.testMaxName
test_socket.TestLinuxAbstractNamespace.testNameOverflow
test_socket.GeneralModuleTests.*
'''
tests = [x.strip().replace('\.', '\\.').replace('*', '.*?') for x in tests.split('\n') if x.strip()]
tests = re.compile('^%s$' % '|'.join(tests))
def get_switch_expected(fullname):
"""
>>> get_switch_expected('test_select.SelectTestCase.test_error_conditions')
False
>>> get_switch_expected('test_socket.GeneralModuleTests.testCrucialConstants')
False
>>> get_switch_expected('test_socket.SomeOtherTest.testHello')
True
"""
if tests.match(fullname) is not None:
print fullname
return False
return True
disabled_tests = [
# uses signal module which does not work with gevent (use gevent.signal())
......
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