本文整理汇总了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')
示例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)
示例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()
示例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)
示例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)
示例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()
示例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
示例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.
示例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
示例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)
示例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
示例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)
示例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)
示例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()
示例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)