本文整理汇总了Python中pyfakefs.fake_filesystem.FakeOsModule方法的典型用法代码示例。如果您正苦于以下问题:Python fake_filesystem.FakeOsModule方法的具体用法?Python fake_filesystem.FakeOsModule怎么用?Python fake_filesystem.FakeOsModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyfakefs.fake_filesystem
的用法示例。
在下文中一共展示了fake_filesystem.FakeOsModule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBuildInfoSave
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [as 别名]
def testBuildInfoSave(self, build_info, sv):
fs = fake_filesystem.FakeFilesystem()
installer.open = fake_filesystem.FakeFileOpen(fs)
installer.os = fake_filesystem.FakeOsModule(fs)
timer_root = r'{0}\{1}'.format(installer.constants.REG_ROOT, 'Timers')
fs.CreateFile(
'{}/build_info.yaml'.format(installer.constants.SYS_CACHE),
contents='{BUILD: {opt 1: true, TIMER_opt 2: some value, opt 3: 12345}}\n'
)
s = installer.BuildInfoSave(None, build_info)
s.Run()
sv.assert_has_calls([
mock.call('opt 1', True, 'HKLM', installer.constants.REG_ROOT),
mock.call('TIMER_opt 2', 'some value', 'HKLM', timer_root),
mock.call('opt 3', 12345, 'HKLM', installer.constants.REG_ROOT),
], any_order=True)
s.Run()
示例2: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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')
示例3: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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)
示例4: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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()
示例5: playbook_treeview
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [as 别名]
def playbook_treeview(playbook):
"""
Creates a fake filesystem with playbook files and uses generate_tree() to
recurse and return a JSON structure suitable for bootstrap-treeview.
"""
fs = fake_filesystem.FakeFilesystem()
mock_os = fake_filesystem.FakeOsModule(fs)
files = models.File.query.filter(models.File.playbook_id.in_([playbook]))
paths = {}
for file in files:
fs.CreateFile(file.path)
paths[file.path] = file.id
return jsonutils.dumps(generate_tree('/', paths, mock_os),
sort_keys=True,
indent=2)
示例6: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [as 别名]
def setUp(self, tk):
super(ChooserTest, self).setUp()
self.ui = chooser.Chooser(_TEST_CONF, preload=False)
self.tk = tk
v1 = mock.Mock()
v1.Value.return_value = 'value1'
v2 = mock.Mock()
v2.Value.return_value = 'value2'
v3 = mock.Mock()
v3.Value.return_value = 'value3'
self.ui.fields = {'field1': v1, 'field2': v2, 'field3': v3}
self.fs = fake_filesystem.FakeFilesystem()
chooser.resources.os = fake_filesystem.FakeOsModule(self.fs)
self.fs.CreateFile('/resources/logo.gif')
示例7: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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)
示例8: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [as 别名]
def setUp(self):
super(PowershellTest, self).setUp()
self.fs = fake_filesystem.FakeFilesystem()
powershell.os = fake_filesystem.FakeOsModule(self.fs)
powershell.resources.os = fake_filesystem.FakeOsModule(self.fs)
self.path = '/resources/bin/script.ps1'
self.fs.CreateFile(self.path)
self.ps = powershell.PowerShell()
示例9: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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)
示例10: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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()
示例11: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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
示例12: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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)
示例13: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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
示例14: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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)
示例15: setUp
# 需要导入模块: from pyfakefs import fake_filesystem [as 别名]
# 或者: from pyfakefs.fake_filesystem import FakeOsModule [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)