本文整理汇总了Python中webkitpy.tool.mocktool.MockTool类的典型用法代码示例。如果您正苦于以下问题:Python MockTool类的具体用法?Python MockTool怎么用?Python MockTool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockTool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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])
示例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)
示例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
示例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
示例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)
示例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)
示例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])
示例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))
示例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)
示例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)
示例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)
示例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)
示例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(), [])
示例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)