本文整理汇总了Python中webkitpy.tool.mocktool.MockTool类的典型用法代码示例。如果您正苦于以下问题:Python MockTool类的具体用法?Python MockTool怎么用?Python MockTool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockTool类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_rebaseline_multiple_builders_and_tests_command_line
def test_rebaseline_multiple_builders_and_tests_command_line(self):
old_exact_matches = builders._exact_matches
try:
builders._exact_matches = {
"MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])},
"MOCK builder2": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier2"])},
"MOCK builder3": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier2"])},
}
command = Rebaseline()
tool = MockTool()
command.bind_to_tool(tool)
for port_name in tool.port_factory.all_port_names():
port = tool.port_factory.get(port_name)
for path in port.expectations_files():
tool.filesystem.write_text_file(path, '')
tool.executive = MockExecutive(should_log=True)
expected_stdout = """rebaseline-json: {'mock/path/to/test.html': {'MOCK builder2': ['txt', 'png', 'wav'], 'MOCK builder': ['txt', 'png', 'wav'], 'MOCK builder3': ['txt', 'png', 'wav']}, 'mock/path/to/test2.html': {'MOCK builder2': ['txt', 'png', 'wav'], 'MOCK builder': ['txt', 'png', 'wav'], 'MOCK builder3': ['txt', 'png', 'wav']}}
"""
expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png,wav', '--builder', 'MOCK builder2', '--test', 'mock/path/to/test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png,wav', '--builder', 'MOCK builder', '--test', 'mock/path/to/test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png,wav', '--builder', 'MOCK builder2', '--test', 'mock/path/to/test2.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png,wav', '--builder', 'MOCK builder', '--test', 'mock/path/to/test2.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'wav,txt,png', 'mock/path/to/test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'wav,txt,png', 'mock/path/to/test2.html'], cwd=/mock-checkout
"""
OutputCapture().assert_outputs(self, command.execute, [MockOptions(optimize=True, builders=["MOCK builder,MOCK builder2", "MOCK builder3"], suffixes=["txt", "png,wav"], verbose=True), ["mock/path/to/test.html", "mock/path/to/test2.html"], tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
finally:
builders._exact_matches = old_exact_matches
开发者ID:,项目名称:,代码行数:35,代码来源:
示例2: _test_check_test_expectations
def _test_check_test_expectations(self, filename):
capture = OutputCapture()
options = MockOptions()
options.git_commit = ""
options.non_interactive = True
tool = MockTool()
tool.user = None # Will cause any access of tool.user to raise an exception.
step = Commit(tool, options)
state = {
"changed_files": [filename + "XXX"],
}
tool.executive = MockExecutive(should_log=True, should_throw_when_run=False)
expected_logs = "Committed r49824: <http://trac.webkit.org/changeset/49824>\n"
capture.assert_outputs(self, step.run, [state], expected_logs=expected_logs)
state = {
"changed_files": ["platform/chromium/" + filename],
}
expected_logs = """MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/%s'], cwd=/mock-checkout
Committed r49824: <http://trac.webkit.org/changeset/49824>
""" % filename
capture.assert_outputs(self, step.run, [state], expected_logs=expected_logs)
tool.executive = MockExecutive(should_log=True, should_throw_when_run=set(["platform/chromium/" + filename]))
self.assertRaises(ScriptError, capture.assert_outputs, self, step.run, [state])
开发者ID:,项目名称:,代码行数:27,代码来源:
示例3: test_run_working_directory_changes_force
def test_run_working_directory_changes_force(self):
tool = MockTool()
tool._scm = Mock()
step = CleanWorkingDirectory(tool, MockOptions(clean=True, force_clean=True))
tool._scm.has_working_directory_changes = lambda: True
step.run({})
self.assertEqual(tool._scm.discard_working_directory_changes.call_count, 1)
开发者ID:3163504123,项目名称:phantomjs,代码行数:7,代码来源:cleanworkingdirectory_unittest.py
示例4: test_rebaseline_test_internal_with_move_overwritten_baselines_to
def test_rebaseline_test_internal_with_move_overwritten_baselines_to(self):
old_exact_matches = builders._exact_matches
try:
builders._exact_matches = {
"MOCK Leopard": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])},
"MOCK SnowLeopard": {"port_name": "test-mac-snowleopard", "specifiers": set(["mock-specifier"])},
}
command = RebaselineTest()
tool = MockTool()
tool.executive = MockExecutive(should_log=True)
command.bind_to_tool(tool)
port = tool.port_factory.get('test-mac-snowleopard')
tool.filesystem.write_text_file(tool.filesystem.join(port.baseline_version_dir(), 'failures', 'expected', 'image-expected.txt'), '')
options = MockOptions(optimize=True, builder="MOCK SnowLeopard", suffixes="txt",
move_overwritten_baselines_to=["test-mac-leopard"], verbose=True, test="failures/expected/image.html")
oc = OutputCapture()
oc.capture_output()
try:
logs = ''
command.execute(options, [], tool)
finally:
_, _, logs = oc.restore_output()
self.assertTrue("Copying baseline from /test.checkout/LayoutTests/platform/test-mac-snowleopard/failures/expected/image-expected.txt to /test.checkout/LayoutTests/platform/test-mac-leopard/failures/expected/image-expected.txt.\n" in logs)
finally:
builders._exact_matches = old_exact_matches
开发者ID:,项目名称:,代码行数:31,代码来源:
示例5: test_rebaseline_all
def test_rebaseline_all(self):
old_exact_matches = builders._exact_matches
builders._exact_matches = {
"MOCK builder": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier"])},
"MOCK builder (Debug)": {"port_name": "test-mac-leopard", "specifiers": set(["mock-specifier", "debug"])},
}
command = RebaselineJson()
tool = MockTool()
options = MockOptions()
options.optimize = True
command.bind_to_tool(tool)
tool.executive = MockExecutive(should_log=True)
expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--builder', 'MOCK builder', '--test', 'user-scripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'user-scripts/another-test.html'], cwd=/mock-checkout
"""
OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder": ["txt", "png"]}}], expected_stderr=expected_stderr)
expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', '--builder', 'MOCK builder (Debug)', '--test', 'user-scripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt,png', 'user-scripts/another-test.html'], cwd=/mock-checkout
"""
OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt", "png"]}}], expected_stderr=expected_stderr)
expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test-internal', '--suffixes', 'txt', '--builder', 'MOCK builder', '--test', 'user-scripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'optimize-baselines', '--suffixes', 'txt', 'user-scripts/another-test.html'], cwd=/mock-checkout
"""
OutputCapture().assert_outputs(self, command._rebaseline, [options, {"user-scripts/another-test.html":{"MOCK builder (Debug)": ["txt", "png"], "MOCK builder": ["txt"]}}], expected_stderr=expected_stderr)
builders._exact_matches = old_exact_matches
开发者ID:,项目名称:,代码行数:30,代码来源:
示例6: test_fetch_next_work_item
def test_fetch_next_work_item(self):
queue = AbstractPatchQueue()
tool = MockTool()
queue.bind_to_tool(tool)
self.assertEquals(queue._fetch_next_work_item(), None)
tool.status_server = MockStatusServer(work_items=[2, 1, 3])
self.assertEquals(queue._fetch_next_work_item(), 2)
开发者ID:,项目名称:,代码行数:7,代码来源:
示例7: test_no_clean
def test_no_clean(self):
tool = MockTool()
tool._scm = Mock()
step = CleanWorkingDirectory(tool, MockOptions(clean=False))
step.run({})
self.assertEqual(tool._scm.ensure_no_local_commits.call_count, 0)
self.assertEqual(tool._scm.ensure_clean_working_directory.call_count, 0)
开发者ID:Andolamin,项目名称:LunaSysMgr,代码行数:7,代码来源:cleanworkingdirectory_unittest.py
示例8: test_check_test_expectations
def test_check_test_expectations(self):
capture = OutputCapture()
options = MockOptions()
options.git_commit = ""
tool = MockTool()
step = Commit(tool, options)
state = {"changed_files": ["test_expectations.txtXXX"]}
tool.executive = MockExecutive(should_log=True, should_throw_when_run=False)
capture.assert_outputs(
self, step.run, [state], expected_stderr="Committed r49824: <http://trac.webkit.org/changeset/49824>\n"
)
state = {"changed_files": ["platform/chromium/test_expectations.txt"]}
capture.assert_outputs(
self,
step.run,
[state],
expected_stderr="MOCK run_and_throw_if_fail: ['mock-check-webkit-style', '--diff-files', 'platform/chromium/test_expectations.txt'], cwd=/mock-checkout\nCommitted r49824: <http://trac.webkit.org/changeset/49824>\n",
)
tool.executive = MockExecutive(
should_log=True, should_throw_when_run=set(["platform/chromium/test_expectations.txt"])
)
self.assertRaises(SystemExit, capture.assert_outputs, self, step.run, [state])
开发者ID:,项目名称:,代码行数:26,代码来源:
示例9: _assert_emails_for_tests
def _assert_emails_for_tests(self, emails):
queue = CommitQueue()
tool = MockTool()
queue.bind_to_tool(tool)
commit_infos = [MockCommitInfo(email) for email in emails]
tool.checkout().recent_commit_infos_for_files = lambda paths: set(commit_infos)
self.assertEqual(queue._author_emails_for_tests([]), set(emails))
开发者ID:Andersbakken,项目名称:check-coding-style,代码行数:7,代码来源:queues_unittest.py
示例10: test_can_build_and_test
def test_can_build_and_test(self):
queue = CommitQueue()
tool = MockTool()
tool.executive = Mock()
queue.bind_to_tool(tool)
self.assertTrue(queue._can_build_and_test())
expected_run_args = ["echo", "--status-host=example.com", "build-and-test", "--force-clean", "--build", "--test", "--non-interactive", "--no-update", "--build-style=both", "--quiet"]
tool.executive.run_and_throw_if_fail.assert_called_with(expected_run_args)
开发者ID:,项目名称:,代码行数:8,代码来源:
示例11: test_error_local_commits_exist_without_force
def test_error_local_commits_exist_without_force(self):
tool = MockTool()
tool._scm = Mock()
tool._scm.has_working_directory_changes = lambda: False
tool._scm.has_local_commits = lambda: True
step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=False))
self.assertRaises(ScriptError, step.run, {})
self.assertEqual(tool._scm.discard_local_changes.call_count, 0)
开发者ID:3163504123,项目名称:phantomjs,代码行数:8,代码来源:discardlocalchanges_unittest.py
示例12: test_no_changes_exist_with_force
def test_no_changes_exist_with_force(self):
tool = MockTool()
tool._scm = Mock()
tool._scm.has_working_directory_changes = lambda: False
tool._scm.has_local_commits = lambda: False
step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=True))
step.run({})
self.assertEqual(tool._scm.discard_local_changes.call_count, 1)
开发者ID:3163504123,项目名称:phantomjs,代码行数:8,代码来源:discardlocalchanges_unittest.py
示例13: test_run
def test_run(self):
tool = MockTool()
tool._scm = Mock()
tool._scm.checkout_root = '/mock-checkout'
step = CleanWorkingDirectory(tool, MockOptions(clean=True, force_clean=False))
step.run({})
self.assertEqual(tool._scm.ensure_no_local_commits.call_count, 1)
self.assertEqual(tool._scm.ensure_clean_working_directory.call_count, 1)
开发者ID:Andolamin,项目名称:LunaSysMgr,代码行数:8,代码来源:cleanworkingdirectory_unittest.py
示例14: test_missing_unit_test_results_path
def test_missing_unit_test_results_path(self):
tool = MockTool()
tool.port().unit_tests_results_path = lambda: None
reader = LayoutTestResultsReader(tool, "/var/logs")
reader._create_layout_test_results = lambda: LayoutTestResults([])
# layout_test_results shouldn't raise even if the unit tests xml file is missing.
self.assertNotEquals(reader.results(), None)
self.assertEqual(reader.results().failing_tests(), [])
开发者ID:twnin,项目名称:webkit,代码行数:8,代码来源:layouttestresultsreader_unittest.py
示例15: test_rebaseline_expectations
def test_rebaseline_expectations(self):
command = RebaselineExpectations()
tool = MockTool()
command.bind_to_tool(tool)
for port_name in tool.port_factory.all_port_names():
port = tool.port_factory.get(port_name)
tool.filesystem.write_text_file(port.path_to_test_expectations_file(), '')
# Don't enable logging until after we create the mock expectation files as some Port.__init__'s run subcommands.
tool.executive = MockExecutive(should_log=True)
expected_stdout = """Retrieving results for chromium-gpu-mac-snowleopard from Webkit Mac10.6 - GPU.
Retrieving results for chromium-gpu-win-win7 from Webkit Win7 - GPU.
Retrieving results for chromium-gpu-win-xp from Webkit Win - GPU.
Retrieving results for chromium-linux-x86 from Webkit Linux 32.
userscripts/another-test.html
userscripts/images.svg
Retrieving results for chromium-linux-x86_64 from Webkit Linux.
userscripts/another-test.html
userscripts/images.svg
Retrieving results for chromium-mac-leopard from Webkit Mac10.5.
userscripts/another-test.html
userscripts/images.svg
Retrieving results for chromium-mac-snowleopard from Webkit Mac10.6.
userscripts/another-test.html
userscripts/images.svg
Retrieving results for chromium-win-vista from Webkit Vista.
userscripts/another-test.html
userscripts/images.svg
Retrieving results for chromium-win-win7 from Webkit Win7.
userscripts/another-test.html
userscripts/images.svg
Retrieving results for chromium-win-xp from Webkit Win.
userscripts/another-test.html
userscripts/images.svg
Optimizing baselines for userscripts/another-test.html.
Optimizing baselines for userscripts/images.svg.
"""
expected_stderr = """MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux 32', 'userscripts/images.svg'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Linux', 'userscripts/images.svg'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.5', 'userscripts/images.svg'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Mac10.6', 'userscripts/images.svg'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Vista', 'userscripts/images.svg'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win7', 'userscripts/images.svg'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'rebaseline-test', 'Webkit Win', 'userscripts/images.svg'], cwd=/mock-checkout
MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/another-test.html'], cwd=/mock-checkout
MOCK run_command: ['echo', 'optimize-baselines', 'userscripts/images.svg'], cwd=/mock-checkout
"""
command._tests_to_rebaseline = lambda port: [] if not port.name().find('-gpu-') == -1 else ['userscripts/another-test.html', 'userscripts/images.svg']
OutputCapture().assert_outputs(self, command.execute, [None, [], tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
开发者ID:,项目名称:,代码行数:58,代码来源:
示例16: test_land_diff
def test_land_diff(self):
expected_stderr = "Building WebKit\nRunning Python unit tests\nRunning Perl unit tests\nRunning JavaScriptCore tests\nRunning run-webkit-tests\nCommitted r49824: <http://trac.webkit.org/changeset/49824>\nUpdating bug 42\n"
mock_tool = MockTool()
mock_tool.scm().create_patch = Mock(return_value="Patch1\nMockPatch\n")
mock_tool.checkout().modified_changelogs = Mock(return_value=[])
self.assert_execute_outputs(Land(), [42], options=self._default_options(), expected_stderr=expected_stderr, tool=mock_tool)
# Make sure we're not calling expensive calls too often.
self.assertEqual(mock_tool.scm().create_patch.call_count, 1)
self.assertEqual(mock_tool.checkout().modified_changelogs.call_count, 1)
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:9,代码来源:download_unittest.py
示例17: test_missing_layout_test_results
def test_missing_layout_test_results(self):
tool = MockTool()
reader = LayoutTestResultsReader(tool, "/var/logs")
results_path = '/mock-results/results.html'
tool.filesystem = MockFileSystem({results_path: None})
# Make sure that our filesystem mock functions as we expect.
self.assertRaises(IOError, tool.filesystem.read_text_file, results_path)
# layout_test_results shouldn't raise even if the results.html file is missing.
self.assertEquals(reader.results(), None)
开发者ID:Andolamin,项目名称:LunaSysMgr,代码行数:9,代码来源:layouttestresultsreader_unittest.py
示例18: _assert_run_webkit_patch
def _assert_run_webkit_patch(self, run_args):
queue = TestQueue()
tool = MockTool()
tool.executive = Mock()
queue.bind_to_tool(tool)
queue.run_webkit_patch(run_args)
expected_run_args = ["echo", "--status-host=example.com"] + run_args
tool.executive.run_and_throw_if_fail.assert_called_with(expected_run_args)
开发者ID:,项目名称:,代码行数:9,代码来源:
示例19: test_missing_layout_test_results
def test_missing_layout_test_results(self):
queue = CommitQueue()
tool = MockTool()
results_path = '/mock/results.html'
tool.filesystem = MockFileSystem({results_path: None})
queue.bind_to_tool(tool)
# Make sure that our filesystem mock functions as we expect.
self.assertRaises(IOError, tool.filesystem.read_text_file, results_path)
# layout_test_results shouldn't raise even if the results.html file is missing.
self.assertEquals(queue.layout_test_results(), None)
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:10,代码来源:queues_unittest.py
示例20: test_update_command_non_interactive
def test_update_command_non_interactive(self):
tool = MockTool()
options = MockOptions(non_interactive=True)
step = Update(tool, options)
self.assertEqual(["mock-update-webkit"], step._update_command())
tool._deprecated_port = ChromiumPort()
self.assertEqual(["Tools/Scripts/update-webkit", "--chromium", "--force-update"], step._update_command())
tool._deprecated_port = ChromiumXVFBPort()
self.assertEqual(["Tools/Scripts/update-webkit", "--chromium", "--force-update"], step._update_command())
开发者ID:Moondee,项目名称:Artemis,代码行数:11,代码来源:update_unittest.py
注:本文中的webkitpy.tool.mocktool.MockTool类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论