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


Python fake_filesystem.FakeFileOpen方法代码示例

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


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

示例1: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(DeployImplTest, self).setUp()
    # Save the real modules for clean up.
    self.real_open = builtins.open
    # Create a fake file system and stub out builtin modules.
    self.fs = fake_filesystem.FakeFilesystem()
    self.os = fake_filesystem.FakeOsModule(self.fs)
    self.open = fake_filesystem.FakeFileOpen(self.fs)
    self.shutil = fake_filesystem_shutil.FakeShutilModule(self.fs)
    self.stubs = mox3_stubout.StubOutForTesting()
    self.stubs.SmartSet(builtins, 'open', self.open)
    self.stubs.SmartSet(deploy_impl, 'os', self.os)
    self.stubs.SmartSet(deploy_impl, 'shutil', self.shutil)
    # Populate the fake file system with the expected directories and files.
    self.fs.CreateDirectory('/this/is/a/workspace/loaner/web_app/frontend/dist')
    self.fs.CreateDirectory('/this/is/a/workspace/loaner/chrome_app/dist')
    self.fs.CreateFile('/this/is/a/workspace/loaner/web_app/app.yaml')
    self.fs.CreateFile('/this/is/a/workspace/loaner/web_app/endpoints.yaml') 
开发者ID:google,项目名称:loaner,代码行数:20,代码来源:deploy_impl_test.py

示例2: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(AuthTest, self).setUp()
    self._test_project = 'test_project'
    self._test_client_id = 'test_client_id'
    self._test_client_secret = 'test_client_secret'
    self._test_config = common.ProjectConfig(
        'test_key', self._test_project, self._test_client_id,
        self._test_client_secret, None, '/test/path.yaml')
    # Save the real modules for clean up.
    self.real_open = builtins.open
    # Create a fake file system and stub out builtin modules.
    self.fs = fake_filesystem.FakeFilesystem()
    self.os = fake_filesystem.FakeOsModule(self.fs)
    self.open = fake_filesystem.FakeFileOpen(self.fs)
    self.stubs = mox3_stubout.StubOutForTesting()
    self.stubs.SmartSet(builtins, 'open', self.open)
    self.stubs.SmartSet(auth, 'os', self.os) 
开发者ID:google,项目名称:loaner,代码行数:19,代码来源:auth_test.py

示例3: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(ConfigurationTest, self).setUp()
    # Save the real modules for clean up.
    self.real_open = __builtin__.open
    self.real_file = __builtin__.file
    self.fs = fake_filesystem.FakeFilesystem()
    self.os = fake_filesystem.FakeOsModule(self.fs)
    self.open = fake_filesystem.FakeFileOpen(self.fs)
    self.stubs = mox3_stubout.StubOutForTesting()
    self.stubs.SmartSet(__builtin__, 'open', self.open)
    self.stubs.SmartSet(os, 'path', self.os.path)

    config_file = constants.CONFIG_DEFAULTS_PATH
    self.fs.CreateFile(config_file, contents=_config_defaults_yaml)

    config_model.Config(id='string_config', string_value='config value 1').put()
    config_model.Config(id='integer_config', integer_value=1).put()
    config_model.Config(id='bool_config', bool_value=True).put()
    config_model.Config(id='list_config', list_value=['email1', 'email2']).put() 
开发者ID:google,项目名称:loaner,代码行数:21,代码来源:config_model_test.py

示例4: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(FileUtilTest, self).setUp()
    self.filesystem = fake_filesystem.FakeFilesystem()
    file_util.os = fake_filesystem.FakeOsModule(self.filesystem)
    file_util.open = fake_filesystem.FakeFileOpen(self.filesystem) 
开发者ID:google,项目名称:glazier,代码行数:7,代码来源:file_util_test.py

示例5: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(IdentifierTest, self).setUp()
    mock_wmi = mock.patch.object(
        identifier.hw_info.wmi_query, 'WMIQuery', autospec=True)
    self.addCleanup(mock_wmi.stop)
    mock_wmi.start()
    self.fs = fake_filesystem.FakeFilesystem()
    identifier.open = fake_filesystem.FakeFileOpen(self.fs)
    identifier.os = fake_filesystem.FakeOsModule(self.fs) 
开发者ID:google,项目名称:glazier,代码行数:11,代码来源:identifier_test.py

示例6: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(BeyondcorpTest, self).setUp()
    self.__saved_flags = flagsaver.save_flag_values()
    mock_wmi = mock.patch.object(
        beyondcorp.hw_info.wmi_query, 'WMIQuery', autospec=True)
    self.addCleanup(mock_wmi.stop)
    mock_wmi.start()
    self.filesystem = fake_filesystem.FakeFilesystem()
    self.filesystem.CreateFile(r'C:\seed.json', contents=_TEST_SEED)
    self.filesystem.CreateFile(beyondcorp.constants.USB_WIM, contents=_TEST_WIM)
    beyondcorp.os = fake_filesystem.FakeOsModule(self.filesystem)
    beyondcorp.open = fake_filesystem.FakeFileOpen(self.filesystem)
    self.beyondcorp = beyondcorp.BeyondCorp() 
开发者ID:google,项目名称:glazier,代码行数:15,代码来源:beyondcorp_test.py

示例7: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(FileSystemTest, self).setUp()
    # fake filesystem
    fs = fake_filesystem.FakeFilesystem()
    fs.CreateDirectory(r'/stage')
    fs.CreateFile(r'/stage/file1.txt', contents='file1')
    fs.CreateFile(r'/stage/file2.txt', contents='file2')
    self.fake_open = fake_filesystem.FakeFileOpen(fs)
    file_system.os = fake_filesystem.FakeOsModule(fs)
    file_system.shutil = fake_filesystem_shutil.FakeShutilModule(fs)
    file_system.open = self.fake_open
    self.fs = fs 
开发者ID:google,项目名称:glazier,代码行数:14,代码来源:file_system_test.py

示例8: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(FilesTest, self).setUp()
    self.filesystem = fake_filesystem.FakeFilesystem()
    files.open = fake_filesystem.FakeFileOpen(self.filesystem)
    files.file_util.shutil = fake_filesystem_shutil.FakeShutilModule(
        self.filesystem)
    files.WindowsError = Exception

  # TODO: Split into separate tests. 
开发者ID:google,项目名称:glazier,代码行数:11,代码来源:files_test.py

示例9: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(SysprepTest, self).setUp()
    fs = fake_filesystem.FakeFilesystem()
    fs.CreateDirectory('/windows/panther')
    fs.CreateFile('/windows/panther/unattend.xml', contents=UNATTEND_XML)
    self.fake_open = fake_filesystem.FakeFileOpen(fs)
    sysprep.os = fake_filesystem.FakeOsModule(fs)
    sysprep.open = self.fake_open 
开发者ID:google,项目名称:glazier,代码行数:10,代码来源:sysprep_test.py

示例10: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(ExecuteTest, self).setUp()
    self.fs = fake_filesystem.FakeFilesystem()
    execute.os = fake_filesystem.FakeOsModule(self.fs)
    execute.open = fake_filesystem.FakeFileOpen(self.fs)
    self.binary = r'C:\foo.exe'
    self.fs.CreateFile(self.binary) 
开发者ID:google,项目名称:glazier,代码行数:9,代码来源:execute_test.py

示例11: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(CacheTest, self).setUp()
    self.cache = cache.Cache()
    fs = fake_filesystem.FakeFilesystem()
    fs.CreateDirectory(r'C:\Directory')
    os_module = fake_filesystem.FakeOsModule(fs)
    self.mock_open = fake_filesystem.FakeFileOpen(fs)
    cache.os = os_module
    cache.open = self.mock_open 
开发者ID:google,项目名称:glazier,代码行数:11,代码来源:cache_test.py

示例12: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(DownloadTest, self).setUp()
    self._dl = download.BaseDownloader()
    # filesystem
    self.filesystem = fake_filesystem.FakeFilesystem()
    self.filesystem.CreateFile(r'C:\input.ini', contents=_TEST_INI)
    download.os = fake_filesystem.FakeOsModule(self.filesystem)
    download.open = fake_filesystem.FakeFileOpen(self.filesystem) 
开发者ID:google,项目名称:glazier,代码行数:10,代码来源:download_test.py

示例13: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(FilesTest, self).setUp()
    self.filesystem = fake_filesystem.FakeFilesystem()
    files.open = fake_filesystem.FakeFileOpen(self.filesystem)
    files.file_util.os = fake_filesystem.FakeOsModule(self.filesystem) 
开发者ID:google,项目名称:glazier,代码行数:7,代码来源:files_test.py

示例14: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(BuildInfoTest, self).setUp()
    # fake filesystem
    self.filesystem = fake_filesystem.FakeFilesystem()
    self.filesystem.CreateDirectory('/dev')
    buildinfo.os = fake_filesystem.FakeOsModule(self.filesystem)
    buildinfo.open = fake_filesystem.FakeFileOpen(self.filesystem)
    # setup
    mock_wmi = mock.patch.object(
        buildinfo.hw_info.wmi_query, 'WMIQuery', autospec=True)
    self.addCleanup(mock_wmi.stop)
    mock_wmi.start()
    self.buildinfo = buildinfo.BuildInfo() 
开发者ID:google,项目名称:glazier,代码行数:15,代码来源:buildinfo_test.py

示例15: setUp

# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeFileOpen [as 别名]
def setUp(self):
    super(CommonTest, self).setUp()
    # Save the real modules for clean up.
    self.real_open = builtins.open
    # Create a fake file system and stub out builtin modules.
    self.fs = fake_filesystem.FakeFilesystem()
    self.os = fake_filesystem.FakeOsModule(self.fs)
    self.open = fake_filesystem.FakeFileOpen(self.fs)
    self.stubs = mox3_stubout.StubOutForTesting()
    self.stubs.SmartSet(builtins, 'open', self.open)
    self.stubs.SmartSet(common, 'os', self.os) 
开发者ID:google,项目名称:loaner,代码行数:13,代码来源:common_test.py


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