当前位置: 首页>>代码示例>>Python>>正文


Python test_parser.TestParser类代码示例

本文整理汇总了Python中webkitpy.w3c.test_parser.TestParser的典型用法代码示例。如果您正苦于以下问题:Python TestParser类的具体用法?Python TestParser怎么用?Python TestParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_analyze_test_reftest_multiple_matches

    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"
        )
开发者ID:zhangdinet,项目名称:blink,代码行数:26,代码来源:test_parser_unittest.py

示例2: test_analyze_wpt_manual_test

    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')
开发者ID:mirror,项目名称:chromium,代码行数:25,代码来源:test_parser_unittest.py

示例3: test_analyze_test_reftest_with_ref_support_Files

    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')
开发者ID:335969568,项目名称:Blink-1,代码行数:30,代码来源:test_parser_unittest.py

示例4: test_analyze_pixel_test_all_true

    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')
开发者ID:335969568,项目名称:Blink-1,代码行数:28,代码来源:test_parser_unittest.py

示例5: test_analyze_test_reftest_match_and_mismatch

    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')
开发者ID:335969568,项目名称:Blink-1,代码行数:25,代码来源:test_parser_unittest.py

示例6: find_importable_tests

    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})
开发者ID:,项目名称:,代码行数:58,代码来源:

示例7: is_js_test

    def is_js_test(self, test_path):
        """Checks whether a given file is a testharness.js test.

        Args:
            test_path: A file path relative to the layout tests directory.
                This might correspond to a deleted file or a non-test.
        """
        absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir(), test_path)
        test_parser = TestParser(absolute_path, self.host)
        if not test_parser.test_doc:
            return False
        return test_parser.is_jstest()
开发者ID:,项目名称:,代码行数:12,代码来源:

示例8: test_analyze_manual_wpt_test

    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')
开发者ID:edcwconan,项目名称:webkit,代码行数:13,代码来源:test_parser_unittest.py

示例9: test_analyze_manual_wpt_test

    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')
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:13,代码来源:test_parser_unittest.py

示例10: test_analyze_test_reftest_one_match

    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')
开发者ID:335969568,项目名称:Blink-1,代码行数:15,代码来源:test_parser_unittest.py

示例11: test_analyze_jstest

    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')
开发者ID:335969568,项目名称:Blink-1,代码行数:17,代码来源:test_parser_unittest.py

示例12: test_reference_test

    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')
开发者ID:edcwconan,项目名称:webkit,代码行数:22,代码来源:test_parser_unittest.py

示例13: test_analyze_csswg_manual_test

    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')
开发者ID:mirror,项目名称:chromium,代码行数:23,代码来源:test_parser_unittest.py

示例14: test_analyze_pixel_test_all_false

    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')
开发者ID:ollie314,项目名称:chromium,代码行数:23,代码来源:test_parser_unittest.py

示例15: test_analyze_test_reftest_multiple_matches

    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')
开发者ID:Anthony-Biget,项目名称:openjfx,代码行数:24,代码来源:test_parser_unittest.py


注:本文中的webkitpy.w3c.test_parser.TestParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。