本文整理汇总了Python中webkitpy.common.system.filesystem_mock.MockFileSystem.write_text_file方法的典型用法代码示例。如果您正苦于以下问题:Python MockFileSystem.write_text_file方法的具体用法?Python MockFileSystem.write_text_file怎么用?Python MockFileSystem.write_text_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webkitpy.common.system.filesystem_mock.MockFileSystem
的用法示例。
在下文中一共展示了MockFileSystem.write_text_file方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_prepend_text
# 需要导入模块: from webkitpy.common.system.filesystem_mock import MockFileSystem [as 别名]
# 或者: from webkitpy.common.system.filesystem_mock.MockFileSystem import write_text_file [as 别名]
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())
示例2: test_set_reviewer
# 需要导入模块: from webkitpy.common.system.filesystem_mock import MockFileSystem [as 别名]
# 或者: from webkitpy.common.system.filesystem_mock.MockFileSystem import write_text_file [as 别名]
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 = u"%s\n%s" % (self._new_entry_boilerplate_with_unreviewed, self._example_changelog)
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)
self.assertEqual(actual_contents.splitlines(), changelog_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())
示例3: test_set_short_description_and_bug_url
# 需要导入模块: from webkitpy.common.system.filesystem_mock import MockFileSystem [as 别名]
# 或者: from webkitpy.common.system.filesystem_mock.MockFileSystem import write_text_file [as 别名]
def test_set_short_description_and_bug_url(self):
fs = MockFileSystem()
changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_bugurl, self._example_changelog)
fs.write_text_file(self._changelog_path, changelog_contents)
short_description = "A short description"
bug_url = "http://example.com/b/2344"
ChangeLog(self._changelog_path, fs).set_short_description_and_bug_url(short_description, bug_url)
actual_contents = fs.read_text_file(self._changelog_path)
expected_message = "%s\n %s" % (short_description, bug_url)
expected_contents = changelog_contents.replace("Need a short description (OOPS!).", expected_message)
self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)
fs.write_text_file(self._changelog_path, changelog_contents)
short_description = "A short description 2"
bug_url = "http://example.com/b/2345"
ChangeLog(self._changelog_path, fs).set_short_description_and_bug_url(short_description, bug_url)
actual_contents = fs.read_text_file(self._changelog_path)
expected_message = "%s\n %s" % (short_description, bug_url)
expected_contents = changelog_contents.replace("Need a short description (OOPS!).\n Need the bug URL (OOPS!).", expected_message)
self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
示例4: test_delete_entries
# 需要导入模块: from webkitpy.common.system.filesystem_mock import MockFileSystem [as 别名]
# 或者: from webkitpy.common.system.filesystem_mock.MockFileSystem import write_text_file [as 别名]
def test_delete_entries(self):
fs = MockFileSystem()
fs.write_text_file(self._changelog_path, self._example_changelog)
ChangeLog(self._changelog_path, fs).delete_entries(8)
actual_contents = fs.read_text_file(self._changelog_path)
expected_contents = """2011-10-11 Antti Koivisto <[email protected]>
Resolve regular and visited link style in a single pass
https://bugs.webkit.org/show_bug.cgi?id=69838
Reviewed by Darin Adler
We can simplify and speed up selector matching by removing the recursive matching done
to generate the style for the :visited pseudo selector. Both regular and visited link style
can be generated in a single pass through the style selector.
== Rolled over to ChangeLog-2009-06-16 ==
"""
self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
ChangeLog(self._changelog_path, fs).delete_entries(2)
actual_contents = fs.read_text_file(self._changelog_path)
expected_contents = "== Rolled over to ChangeLog-2009-06-16 ==\n"
self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
示例5: test_overrides_and_builder_names
# 需要导入模块: from webkitpy.common.system.filesystem_mock import MockFileSystem [as 别名]
# 或者: from webkitpy.common.system.filesystem_mock.MockFileSystem import write_text_file [as 别名]
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)
chromium_overrides_path = port.path_from_chromium_base(
'webkit', 'tools', 'layout_tests', 'test_expectations.txt')
CHROMIUM_OVERRIDES = 'contents of %s\n' % chromium_overrides_path
filesystem.write_text_file(chromium_overrides_path, CHROMIUM_OVERRIDES)
skia_overrides_path = port.path_from_chromium_base(
'skia', 'skia_test_expectations.txt')
SKIA_OVERRIDES = 'contents of %s\n' % skia_overrides_path
filesystem.write_text_file(skia_overrides_path, SKIA_OVERRIDES)
additional_expectations_path = port.path_from_chromium_base(
'additional_expectations.txt')
ADDITIONAL_EXPECTATIONS = 'contents of %s\n' % additional_expectations_path
filesystem.write_text_file(additional_expectations_path, ADDITIONAL_EXPECTATIONS)
port._options.builder_name = 'DUMMY_BUILDER_NAME'
port._options.additional_expectations = []
self.assertEquals(port.test_expectations_overrides(),
SKIA_OVERRIDES + CHROMIUM_OVERRIDES)
port._options.additional_expectations = [additional_expectations_path]
self.assertEquals(port.test_expectations_overrides(),
SKIA_OVERRIDES + CHROMIUM_OVERRIDES + ADDITIONAL_EXPECTATIONS)
port._options.builder_name = 'builder (deps)'
port._options.additional_expectations = []
self.assertEquals(port.test_expectations_overrides(),
SKIA_OVERRIDES + CHROMIUM_OVERRIDES)
port._options.additional_expectations = [additional_expectations_path]
self.assertEquals(port.test_expectations_overrides(),
SKIA_OVERRIDES + CHROMIUM_OVERRIDES + ADDITIONAL_EXPECTATIONS)
# A builder which does NOT observe the Chromium test_expectations,
# but still observes the Skia test_expectations...
port._options.builder_name = 'builder'
port._options.additional_expectations = []
self.assertEquals(port.test_expectations_overrides(),
SKIA_OVERRIDES)
port._options.additional_expectations = [additional_expectations_path]
self.assertEquals(port.test_expectations_overrides(),
SKIA_OVERRIDES + ADDITIONAL_EXPECTATIONS)
示例6: test_platform_duplicate_touched_test
# 需要导入模块: from webkitpy.common.system.filesystem_mock import MockFileSystem [as 别名]
# 或者: from webkitpy.common.system.filesystem_mock.MockFileSystem import write_text_file [as 别名]
def test_platform_duplicate_touched_test(self):
paths = ['LayoutTests/test1.html', 'LayoutTests/test1.html', 'LayoutTests/platform/mock1/test2-expected.txt', 'LayoutTests/platform/mock2/test2-expected.txt']
fs = MockFileSystem()
fs.write_text_file('/test.checkout/LayoutTests/test2.html', 'This is a test')
fs, touched_tests = self.touched_files(paths, fs)
self.assertItemsEqual(touched_tests, ['test1.html', 'test2.html'])
示例7: test_expected_touched_test
# 需要导入模块: from webkitpy.common.system.filesystem_mock import MockFileSystem [as 别名]
# 或者: from webkitpy.common.system.filesystem_mock.MockFileSystem import write_text_file [as 别名]
def test_expected_touched_test(self):
paths = ['LayoutTests/test-expected.txt', 'LayoutTests/no-test-expected.txt']
fs = MockFileSystem()
fs.write_text_file('/test.checkout/LayoutTests/test.html', 'This is a test')
fs, touched_tests = self.touched_files(paths, fs)
self.assertItemsEqual(touched_tests, ['test.html'])