863
864
"([#!$%&()+,./:;?@~|^{}\\[\\]`*\\\'\\\"])", r"\\\\\1", expression)
866
class YUIUnitTestCase(TestCase):
867
class AbstractYUITestCase(TestCase):
870
871
js_timeout = 30000
872
875
TIMEOUT = object()
873
876
MISSING_REPORT = object()
875
878
_yui_results = None
880
def __init__(self, methodName=None):
878
881
"""Create a new test case without a choice of test method name.
880
883
Preventing the choice of test method ensures that we can safely
881
884
provide a test ID based on the file path.
883
super(YUIUnitTestCase, self).__init__("checkResults")
885
def initialize(self, test_path):
886
self.test_path = test_path
886
if methodName is None:
887
methodName = self._testMethodName
889
assert methodName == self._testMethodName
890
super(AbstractYUITestCase, self).__init__(methodName)
889
893
"""Return an ID for this test based on the file path."""
890
894
return os.path.relpath(self.test_path, config.root)
893
super(YUIUnitTestCase, self).setUp()
897
super(AbstractYUITestCase, self).setUp()
894
898
# html5browser imports from the gir/pygtk stack which causes
895
899
# twisted tests to break because of gtk's initialize.
896
900
import html5browser
897
901
client = html5browser.Browser()
898
html_uri = 'file://%s' % os.path.join(
899
config.root, 'lib', self.test_path)
900
page = client.load_page(html_uri, timeout=self.js_timeout)
902
page = client.load_page(self.html_uri, timeout=self.js_timeout)
901
903
if page.return_code == page.CODE_FAIL:
902
904
self._yui_results = self.TIMEOUT
944
946
self.assertEqual([], failures, '\n'.join(failures))
949
class YUIUnitTestCase(AbstractYUITestCase):
951
_testMethodName = 'checkResults'
953
def initialize(self, test_path):
954
# The path is a .html file.
955
self.test_path = test_path
956
self.html_uri = 'file://%s' % os.path.join(
957
config.root, 'lib', self.test_path)
947
960
def build_yui_unittest_suite(app_testing_path, yui_test_class):
948
961
suite = unittest.TestSuite()
949
962
testing_path = os.path.join(config.root, 'lib', app_testing_path)