本文整理汇总了Python中webkitpy.common.system.filesystem_mock.MockFileSystem类的典型用法代码示例。如果您正苦于以下问题:Python MockFileSystem类的具体用法?Python MockFileSystem怎么用?Python MockFileSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockFileSystem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_additional_platform_directory
def test_additional_platform_directory(self):
filesystem = MockFileSystem()
options, args = optparse.OptionParser().parse_args([])
port = base.Port(port_name='foo', filesystem=filesystem, options=options)
port.baseline_search_path = lambda: ['LayoutTests/platform/foo']
layout_test_dir = port.layout_tests_dir()
test_file = filesystem.join(layout_test_dir, '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
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
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')
开发者ID:KDE,项目名称:android-qtwebkit,代码行数:30,代码来源:base_unittest.py
示例2: test_find_log_darwin
def test_find_log_darwin(self):
if not SystemHost().platform.is_mac():
return
older_mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28528)
mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28530)
newer_mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28529)
other_process_mock_crash_report = make_mock_crash_report_darwin('FooProcess', 28527)
misformatted_mock_crash_report = 'Junk that should not appear in a crash report' + make_mock_crash_report_darwin('DumpRenderTree', 28526)[200:]
files = {}
files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150718_quadzen.crash'] = older_mock_crash_report
files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150719_quadzen.crash'] = mock_crash_report
files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150720_quadzen.crash'] = newer_mock_crash_report
files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150721_quadzen.crash'] = None
files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150722_quadzen.crash'] = other_process_mock_crash_report
files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150723_quadzen.crash'] = misformatted_mock_crash_report
filesystem = MockFileSystem(files)
crash_logs = CrashLogs(MockSystemHost(filesystem=filesystem))
log = crash_logs.find_newest_log("DumpRenderTree")
self.assertLinesEqual(log, newer_mock_crash_report)
log = crash_logs.find_newest_log("DumpRenderTree", 28529)
self.assertLinesEqual(log, newer_mock_crash_report)
log = crash_logs.find_newest_log("DumpRenderTree", 28530)
self.assertLinesEqual(log, mock_crash_report)
log = crash_logs.find_newest_log("DumpRenderTree", 28531)
self.assertEqual(log, None)
log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0)
self.assertEqual(log, None)
def bad_read(path):
raise IOError('No such file or directory')
filesystem.read_text_file = bad_read
log = crash_logs.find_newest_log("DumpRenderTree", 28531, include_errors=True)
self.assertTrue('No such file or directory' in log)
开发者ID:Moondee,项目名称:Artemis,代码行数:35,代码来源:crashlogs_unittest.py
示例3: 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')
开发者ID:Andolamin,项目名称:LunaSysMgr,代码行数:29,代码来源:base_unittest.py
示例4: test_set_reviewer
def test_set_reviewer(self):
fs = MockFileSystem()
changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_bugurl, self._example_changelog)
reviewer_name = "Test Reviewer"
fs.write_text_file(self._changelog_path, changelog_contents)
ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
actual_contents = fs.read_text_file(self._changelog_path)
expected_contents = changelog_contents.replace("NOBODY (OOPS!)", reviewer_name)
self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
changelog_contents_without_reviewer_line = u"%s\n%s" % (
self._new_entry_boilerplate_without_reviewer_line,
self._example_changelog,
)
fs.write_text_file(self._changelog_path, changelog_contents_without_reviewer_line)
ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
actual_contents = fs.read_text_file(self._changelog_path)
self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
changelog_contents_without_reviewer_line = u"%s\n%s" % (
self._new_entry_boilerplate_without_reviewer_multiple_bugurl,
self._example_changelog,
)
fs.write_text_file(self._changelog_path, changelog_contents_without_reviewer_line)
ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
actual_contents = fs.read_text_file(self._changelog_path)
changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_multiple_bugurl, self._example_changelog)
expected_contents = changelog_contents.replace("NOBODY (OOPS!)", reviewer_name)
self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
开发者ID:,项目名称:,代码行数:30,代码来源:
示例5: test_prepend_text
def test_prepend_text(self):
fs = MockFileSystem()
fs.write_text_file(self._changelog_path, self._example_changelog)
ChangeLog(self._changelog_path, fs).prepend_text(self._example_entry + "\n")
actual_contents = fs.read_text_file(self._changelog_path)
expected_contents = self._example_entry + "\n" + self._example_changelog
self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:7,代码来源:changelog_unittest.py
示例6: DirectoryFileSetTest
class DirectoryFileSetTest(unittest.TestCase):
def setUp(self):
files = {}
files['/test/some-file'] = 'contents'
files['/test/some-other-file'] = 'other contents'
files['/test/b/c'] = 'c'
self._filesystem = MockFileSystem(files)
self._fileset = DirectoryFileSet('/test', self._filesystem)
def test_files_in_namelist(self):
self.assertTrue('some-file' in self._fileset.namelist())
self.assertTrue('some-other-file' in self._fileset.namelist())
self.assertTrue('b/c' in self._fileset.namelist())
def test_read(self):
self.assertEquals('contents', self._fileset.read('some-file'))
def test_open(self):
file = self._fileset.open('some-file')
self.assertEquals('some-file', file.name())
self.assertEquals('contents', file.contents())
def test_extract(self):
self._fileset.extract('some-file', '/test-directory')
contents = self._filesystem.read_text_file('/test-directory/some-file')
self.assertEquals('contents', contents)
def test_extract_deep_file(self):
self._fileset.extract('b/c', '/test-directory')
self.assertTrue(self._filesystem.exists('/test-directory/b/c'))
def test_delete(self):
self.assertTrue(self._filesystem.exists('/test/some-file'))
self._fileset.delete('some-file')
self.assertFalse(self._filesystem.exists('/test/some-file'))
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:35,代码来源:directoryfileset_unittest.py
示例7: test_check
def test_check(self):
errors = []
def mock_handle_style_error(line_number, category, confidence, message):
error = (line_number, category, confidence, message)
errors.append(error)
fs = MockFileSystem()
file_path = "foo.png"
fs.write_binary_file(file_path, "Dummy binary data")
errors = []
checker = PNGChecker(file_path, mock_handle_style_error, MockSystemHost(os_name='linux', filesystem=fs))
checker.check()
self.assertEqual(len(errors), 0)
file_path = "foo-expected.png"
fs.write_binary_file(file_path, "Dummy binary data")
errors = []
checker = PNGChecker(file_path, mock_handle_style_error, MockSystemHost(os_name='linux', filesystem=fs))
checker.check()
self.assertEqual(len(errors), 1)
self.assertEqual(
errors[0],
(0, 'image/png', 5, 'Image lacks a checksum. Generate pngs using run-webkit-tests to ensure they have a checksum.'))
开发者ID:mirror,项目名称:chromium,代码行数:25,代码来源:png_unittest.py
示例8: assert_interpreter_for_content
def assert_interpreter_for_content(self, intepreter, content):
fs = MockFileSystem()
tempfile, temp_name = fs.open_binary_tempfile('')
tempfile.write(content)
tempfile.close()
file_interpreter = Executive.interpreter_for_script(temp_name, fs)
self.assertEqual(file_interpreter, intepreter)
开发者ID:cheekiatng,项目名称:webkit,代码行数:9,代码来源:executive_unittest.py
示例9: test_collect_tests
def test_collect_tests(self):
runner = self.create_runner()
runner._base_path = '/test.checkout/PerformanceTests'
filesystem = MockFileSystem()
filename = filesystem.join(runner._base_path, 'inspector', 'a_file.html')
filesystem.maybe_make_directory(runner._base_path, 'inspector')
filesystem.files[filename] = 'a content'
runner._host.filesystem = filesystem
tests = runner._collect_tests()
self.assertEqual(len(tests), 1)
开发者ID:ruizhang331,项目名称:WebKit,代码行数:10,代码来源:perftestsrunner_unittest.py
示例10: unit_test_filesystem
def unit_test_filesystem(files=None):
"""Return the FileSystem object used by the unit tests."""
test_list = unit_test_list()
files = files or {}
def add_file(files, test, suffix, contents):
dirname = test.name[0:test.name.rfind('/')]
base = test.base
path = LAYOUT_TEST_DIR + '/' + dirname + '/' + base + suffix
files[path] = contents
# Add each test and the expected output, if any.
for test in test_list.tests.values():
add_file(files, test, '.html', '')
if test.is_reftest:
continue
if test.actual_audio:
add_file(files, test, '-expected.wav', test.expected_audio)
continue
add_file(files, test, '-expected.txt', test.expected_text)
add_file(files, test, '-expected.png', test.expected_image)
# Add the test_expectations file.
files[LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt'] = """
WONTFIX : failures/expected/checksum.html = IMAGE
WONTFIX : failures/expected/crash.html = CRASH
WONTFIX : failures/expected/image.html = IMAGE
WONTFIX : failures/expected/audio.html = AUDIO
WONTFIX : failures/expected/image_checksum.html = IMAGE
WONTFIX : failures/expected/mismatch.html = IMAGE
WONTFIX : failures/expected/missing_check.html = MISSING PASS
WONTFIX : failures/expected/missing_image.html = MISSING PASS
WONTFIX : failures/expected/missing_audio.html = MISSING PASS
WONTFIX : failures/expected/missing_text.html = MISSING PASS
WONTFIX : failures/expected/newlines_leading.html = TEXT
WONTFIX : failures/expected/newlines_trailing.html = TEXT
WONTFIX : failures/expected/newlines_with_excess_CR.html = TEXT
WONTFIX : failures/expected/reftest.html = IMAGE
WONTFIX : failures/expected/text.html = TEXT
WONTFIX : failures/expected/timeout.html = TIMEOUT
WONTFIX SKIP : failures/expected/hang.html = TIMEOUT
WONTFIX SKIP : failures/expected/keyboard.html = CRASH
WONTFIX SKIP : failures/expected/exception.html = CRASH
"""
# FIXME: This test was only being ignored because of missing a leading '/'.
# Fixing the typo causes several tests to assert, so disabling the test entirely.
# Add in a file should be ignored by test_files.find().
#files[LAYOUT_TEST_DIR + '/userscripts/resources/iframe.html'] = 'iframe'
fs = MockFileSystem(files, dirs=set(['/mock-checkout'])) # Make sure at least the checkout_root exists as a directory.
fs._tests = test_list
return fs
开发者ID:,项目名称:,代码行数:55,代码来源:
示例11: test_find_log_darwin
def test_find_log_darwin(self):
if not SystemHost().platform.is_mac():
return
older_mock_crash_report = make_mock_crash_report_darwin("DumpRenderTree", 28528)
mock_crash_report = make_mock_crash_report_darwin("DumpRenderTree", 28530)
newer_mock_crash_report = make_mock_crash_report_darwin("DumpRenderTree", 28529)
other_process_mock_crash_report = make_mock_crash_report_darwin("FooProcess", 28527)
misformatted_mock_crash_report = (
"Junk that should not appear in a crash report"
+ make_mock_crash_report_darwin("DumpRenderTree", 28526)[200:]
)
files = {
"/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150718_quadzen.crash": older_mock_crash_report,
"/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150719_quadzen.crash": mock_crash_report,
"/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150720_quadzen.crash": newer_mock_crash_report,
"/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150721_quadzen.crash": None,
"/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150722_quadzen.crash": other_process_mock_crash_report,
"/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150723_quadzen.crash": misformatted_mock_crash_report,
}
filesystem = MockFileSystem(files)
crash_logs = CrashLogs(MockSystemHost(filesystem=filesystem))
log = crash_logs.find_newest_log("DumpRenderTree")
self.assertMultiLineEqual(log, newer_mock_crash_report)
log = crash_logs.find_newest_log("DumpRenderTree", 28529)
self.assertMultiLineEqual(log, newer_mock_crash_report)
log = crash_logs.find_newest_log("DumpRenderTree", 28530)
self.assertMultiLineEqual(log, mock_crash_report)
log = crash_logs.find_newest_log("DumpRenderTree", 28531)
self.assertIsNone(log)
log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0)
self.assertIsNone(log)
def bad_read(path):
raise IOError("IOError: No such file or directory")
def bad_mtime(path):
raise OSError("OSError: No such file or directory")
filesystem.read_text_file = bad_read
log = crash_logs.find_newest_log("DumpRenderTree", 28531, include_errors=True)
self.assertIn("IOError: No such file or directory", log)
filesystem = MockFileSystem(files)
crash_logs = CrashLogs(MockSystemHost(filesystem=filesystem))
filesystem.mtime = bad_mtime
log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0, include_errors=True)
self.assertIn("OSError: No such file or directory", log)
开发者ID:mirror,项目名称:chromium,代码行数:48,代码来源:crashlogs_unittest.py
示例12: MockCheckout
class MockCheckout(object):
def __init__(self):
# FIXME: It's unclear if a MockCheckout is very useful. A normal Checkout
# with a MockSCM/MockFileSystem/MockExecutive is probably better.
self._filesystem = MockFileSystem()
def is_path_to_changelog(self, path):
return self._filesystem.basename(path) == "ChangeLog"
def recent_commit_infos_for_files(self, paths):
return [self.commit_info_for_revision(32)]
def modified_changelogs(self, git_commit, changed_files=None):
# Ideally we'd return something more interesting here. The problem is
# that LandDiff will try to actually read the patch from disk!
return []
def commit_message_for_this_commit(self, git_commit, changed_files=None):
return MockCommitMessage()
def apply_patch(self, patch):
pass
def apply_reverse_diffs(self, revision):
pass
开发者ID:,项目名称:,代码行数:25,代码来源:
示例13: setUp
def setUp(self):
files = {}
files['/test/some-file'] = 'contents'
files['/test/some-other-file'] = 'other contents'
files['/test/b/c'] = 'c'
self._filesystem = MockFileSystem(files)
self._fileset = DirectoryFileSet('/test', self._filesystem)
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:7,代码来源:directoryfileset_unittest.py
示例14: setUp
def setUp(self):
files = {
'/foo/bar/baz.py': '',
'/foo/bar/baz_unittest.py': '',
'/foo2/bar2/baz2.py': '',
'/foo2/bar2/baz2.pyc': '',
'/foo2/bar2/baz2_integrationtest.py': '',
'/foo2/bar2/missing.pyc': '',
'/tmp/another_unittest.py': '',
}
self.fs = MockFileSystem(files)
self.finder = TestFinder(self.fs)
self.finder.add_tree('/foo', 'bar')
self.finder.add_tree('/foo2')
# Here we have to jump through a hoop to make sure test-webkitpy doesn't log
# any messages from these tests :(.
self.root_logger = logging.getLogger()
self.log_handler = None
for h in self.root_logger.handlers:
if getattr(h, 'name', None) == 'webkitpy.test.main':
self.log_handler = h
break
if self.log_handler:
self.log_level = self.log_handler.level
self.log_handler.level = logging.CRITICAL
开发者ID:Moondee,项目名称:Artemis,代码行数:26,代码来源:test_finder_unittest.py
示例15: test_find_log_darwin
def test_find_log_darwin(self):
if not SystemHost().platform.is_mac():
return
crash_logs = self.create_crash_logs_darwin()
log = crash_logs.find_newest_log("DumpRenderTree")
self.assertMultiLineEqual(log, self.newer_mock_crash_report)
log = crash_logs.find_newest_log("DumpRenderTree", 28529)
self.assertMultiLineEqual(log, self.newer_mock_crash_report)
log = crash_logs.find_newest_log("DumpRenderTree", 28530)
self.assertMultiLineEqual(log, self.mock_crash_report)
log = crash_logs.find_newest_log("DumpRenderTree", 28531)
self.assertIsNone(log)
log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0)
self.assertIsNone(log)
def bad_read(path):
raise IOError('IOError: No such file or directory')
def bad_mtime(path):
raise OSError('OSError: No such file or directory')
self.filesystem.read_text_file = bad_read
log = crash_logs.find_newest_log("DumpRenderTree", 28531, include_errors=True)
self.assertIn('IOError: No such file or directory', log)
self.filesystem = MockFileSystem(self.files)
crash_logs = CrashLogs(MockSystemHost(filesystem=self.filesystem))
self.filesystem.mtime = bad_mtime
log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0, include_errors=True)
self.assertIn('OSError: No such file or directory', log)
开发者ID:edcwconan,项目名称:webkit,代码行数:31,代码来源:crashlogs_unittest.py
示例16: setUp
def setUp(self):
self.filesystem = MockFileSystem()
self.http_lock = HttpLock(
None, "WebKitTestHttpd.lock.", "WebKitTest.lock", filesystem=self.filesystem, executive=MockExecutive()
)
# FIXME: Shouldn't we be able to get these values from the http_lock object directly?
self.lock_file_path_prefix = self.filesystem.join(self.http_lock._lock_path, self.http_lock._lock_file_prefix)
self.lock_file_name = self.lock_file_path_prefix + "0"
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:8,代码来源:http_lock_unittest.py
示例17: test_overrides_and_builder_names
def test_overrides_and_builder_names(self):
port = self.make_port()
filesystem = MockFileSystem()
port._filesystem = filesystem
port.path_from_chromium_base = lambda *comps: '/' + '/'.join(comps)
overrides_path = port.path_from_chromium_base('webkit', 'tools', 'layout_tests', 'test_expectations.txt')
OVERRIDES = 'foo'
filesystem.files[overrides_path] = OVERRIDES
port._options.builder_name = 'DUMMY_BUILDER_NAME'
self.assertEquals(port.test_expectations_overrides(), OVERRIDES)
port._options.builder_name = 'builder (deps)'
self.assertEquals(port.test_expectations_overrides(), OVERRIDES)
port._options.builder_name = 'builder'
self.assertEquals(port.test_expectations_overrides(), None)
开发者ID:,项目名称:,代码行数:19,代码来源:
示例18: MockCheckout
class MockCheckout(object):
def __init__(self):
# FIXME: It's unclear if a MockCheckout is very useful. A normal Checkout
# with a MockSCM/MockFileSystem/MockExecutive is probably better.
self._filesystem = MockFileSystem()
# FIXME: This should move onto the Host object, and we should use a MockCommitterList for tests.
_committer_list = CommitterList()
def commit_info_for_revision(self, svn_revision):
# The real Checkout would probably throw an exception, but this is the only way tests have to get None back at the moment.
if not svn_revision:
return None
return CommitInfo(svn_revision, "[email protected]", {
"bug_id": 50000,
"author_name": "Adam Barth",
"author_email": "[email protected]",
"author": self._committer_list.contributor_by_email("[email protected]"),
"reviewer_text": "Darin Adler",
"reviewer": self._committer_list.committer_by_name("Darin Adler"),
"changed_files": [
"path/to/file",
"another/file",
],
})
def is_path_to_changelog(self, path):
return self._filesystem.basename(path) == "ChangeLog"
def bug_id_for_revision(self, svn_revision):
return 12345
def recent_commit_infos_for_files(self, paths):
return [self.commit_info_for_revision(32)]
def modified_changelogs(self, git_commit, changed_files=None):
# Ideally we'd return something more interesting here. The problem is
# that LandDiff will try to actually read the patch from disk!
return []
def commit_message_for_this_commit(self, git_commit, changed_files=None):
return MockCommitMessage()
def chromium_deps(self):
return MockDEPS()
def apply_patch(self, patch):
pass
def apply_reverse_diffs(self, revision):
pass
def suggested_reviewers(self, git_commit, changed_files=None):
# FIXME: We should use a shared mock commiter list.
return [_mock_reviewers[0]]
开发者ID:Moondee,项目名称:Artemis,代码行数:55,代码来源:checkout_mock.py
示例19: test_additional_platform_directory
def test_additional_platform_directory(self):
filesystem = MockFileSystem()
options, args = optparse.OptionParser().parse_args([])
port = base.Port(port_name="foo", filesystem=filesystem, options=options)
port.baseline_search_path = lambda: []
layout_test_dir = port.layout_tests_dir()
test_file = filesystem.join(layout_test_dir, "fast", "test.html")
# No additional platform directory
self.assertEqual(port.expected_baselines(test_file, ".txt"), [(None, "fast/test-expected.txt")])
# Simple additional platform directory
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")]
)
# Multiple additional platform directories
options.additional_platform_directory = ["/foo", "/tmp/local-baselines"]
self.assertEqual(
port.expected_baselines(test_file, ".txt"), [("/tmp/local-baselines", "fast/test-expected.txt")]
)
开发者ID:gwindlord,项目名称:lenovo_b6000-8000_kernel_source,代码行数:23,代码来源:base_unittest.py
示例20: ChangeDirectoryTest
class ChangeDirectoryTest(unittest.TestCase):
_original_directory = "/original"
_checkout_root = "/WebKit"
def setUp(self):
self._log = LogTesting.setUp(self)
self.filesystem = MockFileSystem(
dirs=[self._original_directory, self._checkout_root], cwd=self._original_directory
)
def tearDown(self):
self._log.tearDown()
def _change_directory(self, paths, checkout_root):
return change_directory(self.filesystem, paths=paths, checkout_root=checkout_root)
def _assert_result(
self, actual_return_value, expected_return_value, expected_log_messages, expected_current_directory
):
self.assertEqual(actual_return_value, expected_return_value)
self._log.assertMessages(expected_log_messages)
self.assertEqual(self.filesystem.getcwd(), expected_current_directory)
def test_paths_none(self):
paths = self._change_directory(checkout_root=self._checkout_root, paths=None)
self._assert_result(paths, None, [], self._checkout_root)
def test_paths_convertible(self):
paths = ["/WebKit/foo1.txt", "/WebKit/foo2.txt"]
paths = self._change_directory(checkout_root=self._checkout_root, paths=paths)
self._assert_result(paths, ["foo1.txt", "foo2.txt"], [], self._checkout_root)
def test_with_scm_paths_unconvertible(self):
paths = ["/WebKit/foo1.txt", "/outside/foo2.txt"]
paths = self._change_directory(checkout_root=self._checkout_root, paths=paths)
log_messages = [
"""WARNING: Path-dependent style checks may not work correctly:
One of the given paths is outside the WebKit checkout of the current
working directory:
Path: /outside/foo2.txt
Checkout root: /WebKit
Pass only files below the checkout root to ensure correct results.
See the help documentation for more info.
"""
]
self._assert_result(paths, paths, log_messages, self._original_directory)
开发者ID:dreifachstein,项目名称:chromium-src,代码行数:50,代码来源:main_unittest.py
注:本文中的webkitpy.common.system.filesystem_mock.MockFileSystem类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论