本文整理汇总了Python中webkitpy.w3c.test_parser.TestParser.analyze_test方法的典型用法代码示例。如果您正苦于以下问题:Python TestParser.analyze_test方法的具体用法?Python TestParser.analyze_test怎么用?Python TestParser.analyze_test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webkitpy.w3c.test_parser.TestParser
的用法示例。
在下文中一共展示了TestParser.analyze_test方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_analyze_test_reftest_multiple_matches
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_test_reftest_multiple_matches(self):
test_html = """<head>
<link rel="match" href="green-box-ref.xht" />
<link rel="match" href="blue-box-ref.xht" />
<link rel="match" href="orange-box-ref.xht" />
</head>
"""
oc = OutputCapture()
oc.capture_output()
try:
test_path = "/some/madeup/path/"
parser = TestParser(options, test_path + "somefile.html")
test_info = parser.analyze_test(test_contents=test_html)
finally:
_, _, logs = oc.restore_output()
self.assertNotEqual(test_info, None, "did not find a test")
self.assertTrue("test" in test_info.keys(), "did not find a test file")
self.assertTrue("reference" in test_info.keys(), "did not find a reference file")
self.assertTrue(test_info["reference"].startswith(test_path), "reference path is not correct")
self.assertFalse("refsupport" in test_info.keys(), "there should be no refsupport files for this test")
self.assertFalse("jstest" in test_info.keys(), "test should not have been analyzed as a jstest")
self.assertEqual(
logs, "Multiple references are not supported. Importing the first ref defined in somefile.html\n"
)
示例2: test_analyze_wpt_manual_test
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_wpt_manual_test(self):
"""Tests analyze_test() with a manual test that is not in csswg-test."""
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
test_path = '/some/madeup/path/'
parser = TestParser(test_path + 'somefile-manual.html', MockHost())
test_info = parser.analyze_test(test_contents=test_html)
self.assertNotEqual(test_info, None, 'test_info is None')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertFalse('reference' in test_info.keys(), 'shold not have found a reference file')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertFalse('jstest' in test_info.keys(), 'test should not be a jstest')
示例3: test_analyze_test_reftest_with_ref_support_Files
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_test_reftest_with_ref_support_Files(self):
""" Tests analyze_test() using a reftest that has refers to a reference file outside of the tests directory and the reference file has paths to other support files """
test_html = """<html>
<head>
<link rel="match" href="../reference/green-box-ref.xht" />
</head>
"""
ref_html = """<head>
<link href="support/css/ref-stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
background-image: url("../../support/some-image.png")
</style>
</head>
<body>
<div><img src="../support/black96x96.png" alt="Image download support must be enabled" /></div>
</body>
</html>
"""
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html, ref_contents=ref_html)
self.assertNotEqual(test_info, None, 'did not find a test')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertTrue('reference' in test_info.keys(), 'did not find a reference file')
self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct')
self.assertTrue('refsupport' in test_info.keys(), 'there should be refsupport files for this test')
self.assertEquals(len(test_info['refsupport']), 3, 'there should be 3 support files in this reference')
self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest')
示例4: test_analyze_pixel_test_all_true
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_pixel_test_all_true(self):
""" Tests analyze_test() using a test that is neither a reftest or jstest with all=False """
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
# Set options to 'all' so this gets found
options['all'] = True
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html)
self.assertNotEqual(test_info, None, 'test_info is None')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertFalse('reference' in test_info.keys(), 'shold not have found a reference file')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertFalse('jstest' in test_info.keys(), 'test should not be a jstest')
示例5: test_analyze_test_reftest_match_and_mismatch
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_test_reftest_match_and_mismatch(self):
test_html = """<head>
<link rel="match" href="green-box-ref.xht" />
<link rel="match" href="blue-box-ref.xht" />
<link rel="mismatch" href="orange-box-notref.xht" />
</head>
"""
oc = OutputCapture()
oc.capture_output()
try:
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html)
finally:
_, _, logs = oc.restore_output()
self.assertNotEqual(test_info, None, 'did not find a test')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertTrue('reference' in test_info.keys(), 'did not find a reference file')
self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest')
self.assertEqual(logs, 'Multiple references are not supported. Importing the first ref defined in somefile.html\n')
示例6: find_importable_tests
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def find_importable_tests(self, directory):
# FIXME: use filesystem
for root, dirs, files in os.walk(directory):
_log.info('Scanning ' + root + '...')
total_tests = 0
reftests = 0
jstests = 0
dirs[:] = [subdir for subdir in dirs if self.should_keep_subdir(root, subdir)]
copy_list = []
for filename in files:
# FIXME: This block should really be a separate function, but the early-continues make that difficult.
if filename.startswith('.') or filename.endswith('.pl'):
continue # For some reason the w3c repo contains random perl scripts we don't care about.
fullpath = os.path.join(root, filename)
mimetype = mimetypes.guess_type(fullpath)
if not 'html' in str(mimetype[0]) and not 'application/xhtml+xml' in str(mimetype[0]) and not 'application/xml' in str(mimetype[0]):
copy_list.append({'src': fullpath, 'dest': filename})
continue
test_parser = TestParser(vars(self.options), filename=fullpath)
test_info = test_parser.analyze_test()
if test_info is None:
continue
if 'reference' in test_info.keys():
reftests += 1
total_tests += 1
test_basename = os.path.basename(test_info['test'])
# Add the ref file, following WebKit style.
# FIXME: Ideally we'd support reading the metadata
# directly rather than relying on a naming convention.
# Using a naming convention creates duplicate copies of the
# reference files.
ref_file = os.path.splitext(test_basename)[0] + '-expected'
ref_file += os.path.splitext(test_basename)[1]
copy_list.append({'src': test_info['reference'], 'dest': ref_file, 'reference_support_info': test_info['reference_support_info']})
copy_list.append({'src': test_info['test'], 'dest': filename})
elif 'jstest' in test_info.keys():
jstests += 1
total_tests += 1
copy_list.append({'src': fullpath, 'dest': filename})
else:
total_tests += 1
copy_list.append({'src': fullpath, 'dest': filename})
if copy_list:
# Only add this directory to the list if there's something to import
self.import_list.append({'dirname': root, 'copy_list': copy_list,
'reftests': reftests, 'jstests': jstests, 'total_tests': total_tests})
示例7: test_analyze_manual_wpt_test
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_manual_wpt_test(self):
""" Tests analyze_test() using a manual jstest """
test_html = """<head>
<link href="/resources/testharness.css" rel="stylesheet" type="text/css">
<script src="/resources/testharness.js"></script>
</head>
"""
test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
parser = TestParser(options, os.path.join(test_path, 'somefile-manual.html'))
test_info = parser.analyze_test(test_contents=test_html)
self.assertTrue(test_info['manualtest'], 'test_info is None')
示例8: test_analyze_manual_wpt_test
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_manual_wpt_test(self):
""" Tests analyze_test() using a manual jstest """
test_html = """<head>
<link href="/resources/testharness.css" rel="stylesheet" type="text/css">
<script src="/resources/testharness.js"></script>
</head>
"""
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile-manual.html')
test_info = parser.analyze_test(test_contents=test_html)
self.assertEqual(test_info, None, 'test_info is None')
示例9: test_analyze_test_reftest_one_match
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_test_reftest_one_match(self):
test_html = """<head>
<link rel="match" href="green-box-ref.xht" />
</head>
"""
test_path = "/some/madeup/path/"
parser = TestParser(options, test_path + "somefile.html")
test_info = parser.analyze_test(test_contents=test_html)
self.assertNotEqual(test_info, None, "did not find a test")
self.assertTrue("test" in test_info.keys(), "did not find a test file")
self.assertTrue("reference" in test_info.keys(), "did not find a reference file")
self.assertTrue(test_info["reference"].startswith(test_path), "reference path is not correct")
self.assertFalse("refsupport" in test_info.keys(), "there should be no refsupport files for this test")
self.assertFalse("jstest" in test_info.keys(), "test should not have been analyzed as a jstest")
示例10: test_analyze_jstest
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_jstest(self):
""" Tests analyze_test() using a jstest """
test_html = """<head>
<link href="/resources/testharness.css" rel="stylesheet" type="text/css">
<script src="/resources/testharness.js"></script>
</head>
"""
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html)
self.assertNotEqual(test_info, None, 'test_info is None')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertFalse('reference' in test_info.keys(), 'shold not have found a reference file')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertTrue('jstest' in test_info.keys(), 'test should be a jstest')
示例11: test_reference_test
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_reference_test(self):
""" Tests analyze_test() using a test that is a reference file having a <link rel="match"> tag"""
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="match" href="test-ref.html" />
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
parser = TestParser(options, os.path.join(test_path, 'test-ref.html'))
test_info = parser.analyze_test(test_contents=test_html)
self.assertTrue('referencefile' in test_info, 'test should be detected as reference file')
示例12: test_analyze_pixel_test_all_false
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_pixel_test_all_false(self):
"""Tests analyze_test() using a test that is neither a reftest or jstest, with -all=False"""
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
# Set 'all' to False so this gets skipped.
options = {'all': False}
test_path = '/some/madeup/path/'
parser = TestParser(test_path + 'somefile.html', MockHost(), options)
test_info = parser.analyze_test(test_contents=test_html)
self.assertEqual(test_info, None, 'test should have been skipped')
示例13: test_analyze_csswg_manual_test
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_csswg_manual_test(self):
"""Tests analyze_test() using a test that is neither a reftest or jstest, in csswg-test"""
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
parser = TestParser('/some/csswg-test/path/somefile.html', MockHost())
test_info = parser.analyze_test(test_contents=test_html)
self.assertIsNotNone(test_info, 'test_info should not be None')
self.assertIn('test', test_info.keys(), 'should find a test file')
self.assertNotIn('reference', test_info.keys(), 'shold not have found a reference file')
self.assertNotIn('refsupport', test_info.keys(), 'there should be no refsupport files for this test')
self.assertNotIn('jstest', test_info.keys(), 'test should not be a jstest')
示例14: test_analyze_test_reftest_multiple_matches
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_test_reftest_multiple_matches(self):
test_html = """<head>
<link rel="match" href="green-box-ref.xht" />
<link rel="match" href="blue-box-ref.xht" />
<link rel="match" href="orange-box-ref.xht" />
</head>
"""
oc = OutputCapture()
oc.capture_output()
try:
test_path = '/some/madeup/path/'
parser = TestParser(options, test_path + 'somefile.html')
test_info = parser.analyze_test(test_contents=test_html)
finally:
output, _, _ = oc.restore_output()
self.assertNotEqual(test_info, None, 'did not find a test')
self.assertTrue('test' in test_info.keys(), 'did not find a test file')
self.assertTrue('reference' in test_info.keys(), 'did not find a reference file')
self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct')
self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest')
self.assertTrue(output.startswith('Warning'), 'no warning about multiple matches')
示例15: test_analyze_pixel_test_all_false
# 需要导入模块: from webkitpy.w3c.test_parser import TestParser [as 别名]
# 或者: from webkitpy.w3c.test_parser.TestParser import analyze_test [as 别名]
def test_analyze_pixel_test_all_false(self):
""" Tests analyze_test() using a test that is neither a reftest or jstest, with -all=False """
test_html = """<html>
<head>
<title>CSS Test: DESCRIPTION OF TEST</title>
<link rel="author" title="NAME_OF_AUTHOR" />
<style type="text/css"><![CDATA[
CSS FOR TEST
]]></style>
</head>
<body>
CONTENT OF TEST
</body>
</html>
"""
# Set all to false so this gets skipped
options['all'] = False
test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
parser = TestParser(options, os.path.join(test_path, 'somefile.html'))
test_info = parser.analyze_test(test_contents=test_html)
self.assertEqual(test_info, None, 'test should have been skipped')