本文整理汇总了Python中mock.mock.MagicMock.pw_name方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.pw_name方法的具体用法?Python MagicMock.pw_name怎么用?Python MagicMock.pw_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.pw_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_user_entity
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import pw_name [as 别名]
def _get_user_entity():
user = MagicMock()
user.pw_name='mapred'
user.pw_passwd='x'
user.pw_uid=0
user.pw_gid=0
user.pw_gecos='root'
user.pw_dir='/root'
user.pw_shell='/bin/false'
return user
示例2: test_javaProcs
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import pw_name [as 别名]
def test_javaProcs(self, pwd_getpwuid_mock, buitin_open_mock, os_listdir_mock):
hostInfo = HostInfoLinux()
openRead = MagicMock()
openRead.read.return_value = '/java/;/hadoop/'
buitin_open_mock.side_effect = [openRead, ['Uid: 22']]
pwuid = MagicMock()
pwd_getpwuid_mock.return_value = pwuid
pwuid.pw_name = 'user'
os_listdir_mock.return_value = ['1']
list = []
hostInfo.javaProcs(list)
self.assertEquals(list[0]['command'], '/java/;/hadoop/')
self.assertEquals(list[0]['pid'], 1)
self.assertTrue(list[0]['hadoop'])
self.assertEquals(list[0]['user'], 'user')
示例3: test_javaProcs
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import pw_name [as 别名]
def test_javaProcs(self, pwd_getpwuid_mock, buitin_open_mock, os_listdir_mock):
hostInfo = HostInfo()
openRead = MagicMock()
openRead.read.return_value = "/java/;/hadoop/"
buitin_open_mock.side_effect = [openRead, ["Uid: 22"]]
pwuid = MagicMock()
pwd_getpwuid_mock.return_value = pwuid
pwuid.pw_name = "user"
os_listdir_mock.return_value = ["1"]
list = []
hostInfo.javaProcs(list)
self.assertEquals(list[0]["command"], "/java/;/hadoop/")
self.assertEquals(list[0]["pid"], 1)
self.assertTrue(list[0]["hadoop"])
self.assertEquals(list[0]["user"], "user")