当前位置: 首页>>代码示例>>Python>>正文


Python MockFileSystem.getcwd方法代码示例

本文整理汇总了Python中webkitpy.common.system.filesystem_mock.MockFileSystem.getcwd方法的典型用法代码示例。如果您正苦于以下问题:Python MockFileSystem.getcwd方法的具体用法?Python MockFileSystem.getcwd怎么用?Python MockFileSystem.getcwd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webkitpy.common.system.filesystem_mock.MockFileSystem的用法示例。


在下文中一共展示了MockFileSystem.getcwd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ChangeDirectoryTest

# 需要导入模块: from webkitpy.common.system.filesystem_mock import MockFileSystem [as 别名]
# 或者: from webkitpy.common.system.filesystem_mock.MockFileSystem import getcwd [as 别名]
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,代码行数:52,代码来源:main_unittest.py


注:本文中的webkitpy.common.system.filesystem_mock.MockFileSystem.getcwd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。