本文整理汇总了Python中webkitpy.common.host_mock.MockHost类的典型用法代码示例。如果您正苦于以下问题:Python MockHost类的具体用法?Python MockHost怎么用?Python MockHost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockHost类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_start_cmd
def test_start_cmd(self):
# Fails on win - see https://bugs.webkit.org/show_bug.cgi?id=84726
if sys.platform in ("cygwin", "win32"):
return
def fake_pid(_):
host.filesystem.write_text_file("/tmp/WebKit/httpd.pid", "42")
return True
host = MockHost()
host.executive = MockExecutive(should_log=True)
test_port = test.TestPort(host)
host.filesystem.write_text_file(test_port._path_to_apache_config_file(), "")
server = LayoutTestApacheHttpd(test_port, "/mock/output_dir", number_of_servers=4)
server._check_that_all_ports_are_available = lambda: True
server._is_server_running_on_all_ports = lambda: True
server._wait_for_action = fake_pid
oc = OutputCapture()
try:
oc.capture_output()
server.start()
server.stop()
finally:
_, _, logs = oc.restore_output()
self.assertIn("StartServers 4", logs)
self.assertIn("MinSpareServers 4", logs)
self.assertIn("MaxSpareServers 4", logs)
self.assertTrue(host.filesystem.exists("/mock/output_dir/httpd.conf"))
示例2: get_test_config
def get_test_config(test_files=[], result_files=[]):
# We could grab this from port.layout_tests_dir(), but instantiating a fully mocked port is a pain.
layout_tests_directory = "/mock-checkout/LayoutTests"
results_directory = '/WebKitBuild/Debug/layout-test-results'
host = MockHost()
for file in test_files:
file_path = host.filesystem.join(layout_tests_directory, file)
host.filesystem.files[file_path] = ''
for file in result_files:
file_path = host.filesystem.join(results_directory, file)
host.filesystem.files[file_path] = ''
class TestMacPort(WebKitPort):
port_name = "mac"
def __init__(self, host):
WebKitPort.__init__(self, host, port_name=self.port_name)
return TestConfig(
TestMacPort(host),
layout_tests_directory,
results_directory,
('mac', 'mac-leopard', 'win', 'linux'),
host.filesystem,
host.scm())
示例3: test_run
def test_run(self):
host = MockHost()
host.executive = MockExecutive2(output='mock-output')
git_cl = GitCL(host)
output = git_cl.run(['command'])
self.assertEqual(output, 'mock-output')
self.assertEqual(host.executive.calls, [['git', 'cl', 'command']])
示例4: __init__
def __init__(self, *args, **kwargs):
MockHost.__init__(self, *args, **kwargs)
self._deprecated_port = MockPort()
self.status_server = MockStatusServer()
self.wakeup_event = threading.Event()
示例5: test_create_branch_with_patch
def test_create_branch_with_patch(self):
host = MockHost()
host.filesystem = MockFileSystem()
local_wpt = LocalWPT(host)
local_wpt.create_branch_with_patch('branch-name', 'message', 'patch')
self.assertEqual(len(host.executive.calls), 9)
示例6: touched_files
def touched_files(self, touched_files, fs=None):
host = MockHost()
if fs:
host.filesystem = fs
else:
fs = host.filesystem
port = MockPort(host)
return (fs, LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(touched_files))
示例7: test_run_with_auth
def test_run_with_auth(self):
host = MockHost()
host.executive = MockExecutive2(output='mock-output')
git_cl = GitCL(host, auth_refresh_token_json='token.json')
git_cl.run(['upload'])
self.assertEqual(
host.executive.calls,
[['git', 'cl', 'upload', '--auth-refresh-token-json', 'token.json']])
示例8: test_check_is_functional_cdb_not_found
def test_check_is_functional_cdb_not_found(self):
host = MockHost()
host.executive = MockExecutive(should_throw=True)
build_dir = "/mock-checkout/out/Debug"
host.filesystem.maybe_make_directory(build_dir)
dump_reader = DumpReaderWin(host, build_dir)
self.assertFalse(dump_reader.check_is_functional())
示例9: test_filesystem_walk
def test_filesystem_walk(self):
mock_dir = 'foo'
mock_files = {'foo/bar/baz': '',
'foo/a': '',
'foo/b': '',
'foo/c': ''}
host = MockHost()
host.filesystem = MockFileSystem(files=mock_files)
self.assertEquals(host.filesystem.walk(mock_dir), [('foo', ['bar'], ['a', 'b', 'c']), ('foo/bar', [], ['baz'])])
示例10: test_skipped_entry_dont_exist
def test_skipped_entry_dont_exist(self):
port = MockHost().port_factory.get('qt')
expectations_dict = OrderedDict()
expectations_dict['expectations'] = ''
port.expectations_dict = lambda: expectations_dict
port.skipped_layout_tests = lambda tests: set(['foo/bar/baz.html'])
capture = OutputCapture()
capture.capture_output()
exp = TestExpectations(port)
_, _, logs = capture.restore_output()
self.assertEqual('The following test foo/bar/baz.html from the Skipped list doesn\'t exist\n', logs)
示例11: test_has_changes_in_wpt_looks_at_start_of_string
def test_has_changes_in_wpt_looks_at_start_of_string(self):
host = MockHost()
def run_command_fn(_):
return ("something/something.html\n"
"something/third_party/WebKit/LayoutTests/imported/wpt/something.html\n")
host.executive = MockExecutive2(run_command_fn=run_command_fn)
chromium_wpt = ChromiumWPT(host)
self.assertFalse(chromium_wpt.has_changes_in_wpt('sha'))