本文整理汇总了Python中webkitpy.layout_tests.port.Port类的典型用法代码示例。如果您正苦于以下问题:Python Port类的具体用法?Python Port怎么用?Python Port使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Port类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, host=None, port_name=None, **kwargs):
if not port_name or port_name == 'test':
port_name = 'test-mac-leopard'
host = host or MockHost()
filesystem = self._set_default_overriding_none(kwargs, 'filesystem', unit_test_filesystem())
Port.__init__(self, host, port_name=port_name, **kwargs)
self._results_directory = None
assert filesystem._tests
self._tests = filesystem._tests
self._operating_system = 'mac'
if port_name.startswith('test-win'):
self._operating_system = 'win'
elif port_name.startswith('test-linux'):
self._operating_system = 'linux'
version_map = {
'test-win-xp': 'xp',
'test-win-win7': 'win7',
'test-win-vista': 'vista',
'test-mac-leopard': 'leopard',
'test-mac-snowleopard': 'snowleopard',
'test-linux-x86_64': 'lucid',
}
self._version = version_map[port_name]
self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt'
示例2: __init__
def __init__(self, port_name=None, user=None, filesystem=None, **kwargs):
if not port_name or port_name == 'test':
port_name = 'test-mac-leopard'
user = user or mocktool.MockUser()
filesystem = filesystem or unit_test_filesystem()
Port.__init__(self, port_name=port_name, filesystem=filesystem, user=user, **kwargs)
self._results_directory = None
assert filesystem._tests
self._tests = filesystem._tests
self._operating_system = 'mac'
if port_name.startswith('test-win'):
self._operating_system = 'win'
elif port_name.startswith('test-linux'):
self._operating_system = 'linux'
version_map = {
'test-win-xp': 'xp',
'test-win-win7': 'win7',
'test-win-vista': 'vista',
'test-mac-leopard': 'leopard',
'test-mac-snowleopard': 'snowleopard',
'test-linux-x86_64': 'lucid',
}
self._version = version_map[port_name]
self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt'
示例3: __init__
def __init__(self, host, port_name=None, **kwargs):
# FIXME: Consider updating all of the callers to pass in a port_name so it can be a
# required parameter like all of the other Port objects.
port_name = port_name or 'test-mac-leopard'
Port.__init__(self, host, port_name, **kwargs)
self._tests = unit_test_list()
self._flakes = set()
self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/TestExpectations'
self._results_directory = None
self._operating_system = 'mac'
if port_name.startswith('test-win'):
self._operating_system = 'win'
elif port_name.startswith('test-linux'):
self._operating_system = 'linux'
version_map = {
'test-win-xp': 'xp',
'test-win-win7': 'win7',
'test-win-vista': 'vista',
'test-mac-leopard': 'leopard',
'test-mac-snowleopard': 'snowleopard',
'test-linux-x86_64': 'lucid',
}
self._version = version_map[port_name]
示例4: test_uses_test_expectations_file
def test_uses_test_expectations_file(self):
filesystem = MockFileSystem()
port = Port(port_name='foo', filesystem=filesystem)
port.path_to_test_expectations_file = lambda: '/mock-results/test_expectations.txt'
self.assertFalse(port.uses_test_expectations_file())
port._filesystem = MockFileSystem({'/mock-results/test_expectations.txt': ''})
self.assertTrue(port.uses_test_expectations_file())
示例5: __init__
def __init__(self, host, port_name=None, **kwargs):
Port.__init__(self, host, port_name or TestPort.default_port_name, **kwargs)
self._tests = unit_test_list()
self._flakes = set()
# FIXME: crbug.com/279494. This needs to be in the "real layout tests
# dir" in a mock filesystem, rather than outside of the checkout, so
# that tests that want to write to a TestExpectations file can share
# this between "test" ports and "real" ports. This is the result of
# rebaseline_unittest.py having tests that refer to "real" port names
# and real builders instead of fake builders that point back to the
# test ports. rebaseline_unittest.py needs to not mix both "real" ports
# and "test" ports
self._generic_expectations_path = '/mock-checkout/LayoutTests/TestExpectations'
self._results_directory = None
self._operating_system = 'mac'
if self._name.startswith('test-win'):
self._operating_system = 'win'
elif self._name.startswith('test-linux'):
self._operating_system = 'linux'
version_map = {
'test-win-xp': 'xp',
'test-win-win7': 'win7',
'test-mac-leopard': 'leopard',
'test-mac-snowleopard': 'snowleopard',
'test-linux-x86_64': 'lucid',
}
self._version = version_map[self._name]
示例6: make_driver
def make_driver(self, worker_number=0, xorg_running=False):
port = Port(host=MockSystemHost(log_executive=True), config=MockConfig())
port._server_process_constructor = MockServerProcess
if xorg_running:
port._executive._running_pids['Xorg'] = 108
driver = XvfbDriver(port, worker_number=worker_number, pixel_tests=True)
return driver
示例7: test_test_to_uri
def test_test_to_uri(self):
port = Port()
layout_test_dir = port.layout_tests_dir()
test = 'foo/bar.html'
path = port._filesystem.join(layout_test_dir, test)
if sys.platform == 'win32':
path = path.replace("\\", "/")
self.assertEqual(port.test_to_uri(test), abspath_to_uri(path))
示例8: test_pretty_patch_script_error
def test_pretty_patch_script_error(self):
# FIXME: This is some ugly white-box test hacking ...
port = Port(executive=executive_mock.MockExecutive2(exception=ScriptError))
port._pretty_patch_available = True
self.assertEqual(port.pretty_patch_text("patch.txt"),
port._pretty_patch_error_html)
# This tests repeated calls to make sure we cache the result.
self.assertEqual(port.pretty_patch_text("patch.txt"),
port._pretty_patch_error_html)
示例9: make_driver
def make_driver(self, worker_number=0, xorg_running=False, executive=None):
port = Port(MockSystemHost(log_executive=True, executive=executive), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
port._config.build_directory = lambda configuration: "/mock-build"
port._server_process_constructor = MockServerProcess
if xorg_running:
port._executive._running_pids['Xorg'] = 108
driver = XvfbDriver(port, worker_number=worker_number, pixel_tests=True)
driver._startup_delay_secs = 0
return driver
示例10: test_additional_platform_directory
def test_additional_platform_directory(self):
filesystem = MockFileSystem()
port = Port(port_name='foo', filesystem=filesystem)
port.baseline_search_path = lambda: ['LayoutTests/platform/foo']
layout_test_dir = port.layout_tests_dir()
test_file = 'fast/test.html'
# No additional platform directory
self.assertEqual(
port.expected_baselines(test_file, '.txt'),
[(None, 'fast/test-expected.txt')])
self.assertEqual(port.baseline_path(), 'LayoutTests/platform/foo')
# Simple additional platform directory
port._options.additional_platform_directory = ['/tmp/local-baselines']
filesystem.files = {
'/tmp/local-baselines/fast/test-expected.txt': 'foo',
}
self.assertEqual(
port.expected_baselines(test_file, '.txt'),
[('/tmp/local-baselines', 'fast/test-expected.txt')])
self.assertEqual(port.baseline_path(), '/tmp/local-baselines')
# Multiple additional platform directories
port._options.additional_platform_directory = ['/foo', '/tmp/local-baselines']
self.assertEqual(
port.expected_baselines(test_file, '.txt'),
[('/tmp/local-baselines', 'fast/test-expected.txt')])
self.assertEqual(port.baseline_path(), '/foo')
示例11: test_pretty_patch_os_error
def test_pretty_patch_os_error(self):
port = Port(executive=executive_mock.MockExecutive2(exception=OSError))
oc = outputcapture.OutputCapture()
oc.capture_output()
self.assertEqual(port.pretty_patch_text("patch.txt"),
port._pretty_patch_error_html)
# This tests repeated calls to make sure we cache the result.
self.assertEqual(port.pretty_patch_text("patch.txt"),
port._pretty_patch_error_html)
oc.restore_output()
示例12: test_wdiff_command
def test_wdiff_command(self):
port = Port()
port._path_to_wdiff = lambda: "/path/to/wdiff"
command = port._wdiff_command("/actual/path", "/expected/path")
expected_command = [
"/path/to/wdiff",
"--start-delete=##WDIFF_DEL##",
"--end-delete=##WDIFF_END##",
"--start-insert=##WDIFF_ADD##",
"--end-insert=##WDIFF_END##",
"/actual/path",
"/expected/path",
]
self.assertEqual(command, expected_command)
示例13: test_parse_reftest_list
def test_parse_reftest_list(self):
port = self.make_port(with_tests=True)
port.host.filesystem.files["bar/reftest.list"] = "\n".join(
[
"== test.html test-ref.html",
"",
"# some comment",
"!= test-2.html test-notref.html # more comments",
"== test-3.html test-ref.html",
"== test-3.html test-ref2.html",
"!= test-3.html test-notref.html",
]
)
reftest_list = Port._parse_reftest_list(port.host.filesystem, "bar")
self.assertEqual(
reftest_list,
{
"bar/test.html": [("==", "bar/test-ref.html")],
"bar/test-2.html": [("!=", "bar/test-notref.html")],
"bar/test-3.html": [
("==", "bar/test-ref.html"),
("==", "bar/test-ref2.html"),
("!=", "bar/test-notref.html"),
],
},
)
示例14: __init__
def __init__(self, host, port_name=None, **kwargs):
Port.__init__(self, host, port_name or TestPort.default_port_name, **kwargs)
self._tests = unit_test_list()
self._flakes = set()
self._generic_expectations_path = LAYOUT_TEST_DIR + '/TestExpectations'
self._results_directory = None
self._operating_system = 'mac'
if self._name.startswith('test-win'):
self._operating_system = 'win'
elif self._name.startswith('test-linux'):
self._operating_system = 'linux'
version_map = {
'test-win-xp': 'xp',
'test-win-win7': 'win7',
'test-mac-leopard': 'leopard',
'test-mac-snowleopard': 'snowleopard',
'test-linux-x86_64': 'lucid',
}
self._version = version_map[self._name]
示例15: run_test
def run_test(self, test_input):
if self._current_test_batch is None:
self._current_test_batch = []
test_batches.append(self._current_test_batch)
test_name = test_input.test_name
# In case of reftest, one test calls the driver's run_test() twice.
# We should not add a reference html used by reftests to tests unless include_reference_html parameter
# is explicitly given.
filesystem = self._port.host.filesystem
dirname, filename = filesystem.split(test_name)
if include_reference_html or not Port.is_reference_html_file(filesystem, dirname, filename):
self._current_test_batch.append(test_name)
return TestDriver.run_test(self, test_input)