本文整理汇总了Python中unittest.mock.MagicMock.info方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.info方法的具体用法?Python MagicMock.info怎么用?Python MagicMock.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stop
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_stop(self):
svc = svc_upstart.SvcUpstart(MagicMock(), "foo", {'running': False})
status = MagicMock()
status.info = {'running': True}
self.assertEqual(
svc.ask(status),
"status running → not running\n",
)
示例2: test_remove
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_remove(self):
pkg = pkg_apt.AptPkg(MagicMock(), "foo", {'installed': False})
status = MagicMock()
status.info = {'installed': True}
self.assertEqual(
pkg.ask(status),
"status installed → not installed\n",
)
示例3: test_install
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_install(self):
pkg = pkg_pacman.PacmanPkg(MagicMock(), "foo", {'installed': True})
status = MagicMock()
status.info = {'installed': False}
self.assertEqual(
pkg.ask(status),
"status not installed → installed\n",
)
示例4: test_install
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_install(self):
pkg = pkg_pip.PipPkg(MagicMock(), "foo", {'installed': True})
status = MagicMock()
status.info = {'installed': False, 'version': None}
self.assertEqual(
pkg.ask(status),
"status not installed → installed\n",
)
示例5: test_remove
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_remove(self):
pkg = pkg_pip.PipPkg(MagicMock(), "foo", {'installed': False})
status = MagicMock()
status.info = {'installed': True, 'version': "1.0"}
self.assertEqual(
pkg.ask(status),
"status 1.0 → not installed\n",
)
示例6: test_create
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_create(self):
db = postgres_dbs.PostgresDB(MagicMock(), "foo", {'owner': "bar"})
status = MagicMock()
status.info = {'exists': False, 'needs_fixing': ['existence']}
self.assertEqual(
db.ask(status),
"Doesn't exist. Do you want to create it?",
)
示例7: test_start
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_start(self):
svc = svc_systemd.SvcSystemd(MagicMock(), "foo", {'running': True})
status = MagicMock()
status.info = {'running': False}
self.assertEqual(
svc.ask(status),
"status not running → running\n",
)
示例8: test_drop
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_drop(self):
role = postgres_roles.PostgresRole(MagicMock(), "bw", {'delete': True})
status = MagicMock()
status.info = {
'exists': True,
'needs_fixing': ['existence'],
}
self.assertEqual(
role.ask(status),
"Will be deleted.",
)
示例9: test_create
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_create(self):
role = postgres_roles.PostgresRole(MagicMock(), "bw", {})
status = MagicMock()
status.info = {
'exists': False,
'needs_fixing': ['existence'],
}
self.assertEqual(
role.ask(status),
"Doesn't exist. Do you want to create it?",
)
示例10: create_mock_logger
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def create_mock_logger():
log_mock = MagicMock()
log_mock.debug = MagicMock()
log_mock.verbose = MagicMock()
log_mock.info = MagicMock()
log_mock.quiet = MagicMock()
log_mock.warn = MagicMock()
log_mock.error = MagicMock()
get_logger_mock = MagicMock(return_value=log_mock)
return get_logger_mock, log_mock
示例11: test_drop
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_drop(self):
db = postgres_dbs.PostgresDB(MagicMock(), "foo", {'delete': True})
status = MagicMock()
status.info = {
'exists': True,
'needs_fixing': ['existence'],
'owner': "bar",
}
self.assertEqual(
db.ask(status),
"Will be deleted.",
)
示例12: test_change_owner
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_change_owner(self):
db = postgres_dbs.PostgresDB(MagicMock(), "foo", {'owner': "bar"})
status = MagicMock()
status.info = {
'exists': True,
'needs_fixing': ['owner'],
'owner': "foo",
}
self.assertEqual(
db.ask(status),
"owner foo → bar",
)
示例13: test_change_superuser
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_change_superuser(self):
role = postgres_roles.PostgresRole(MagicMock(), "bw", {'superuser': False})
status = MagicMock()
status.info = {
'exists': True,
'needs_fixing': ['superuser'],
'password_hash': "foo",
'superuser': True,
}
self.assertEqual(
role.ask(status),
"superuser True → False",
)
示例14: make_mock
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def make_mock(json_response):
"""Used in test_interesting.py."""
response_mock = MagicMock()
response_mock.read = Mock(return_value=json_response)
if PY3:
response_mock.status = 200
response_mock.getheader = Mock(return_value='<https://api.github.com/repos/frost-nzcr4/find_forks/forks?page=2>; rel="next", '
'<https://api.github.com/repos/frost-nzcr4/find_forks/forks?page=3>; rel="last"')
else:
response_mock.code = 200
response_mock.info = Mock(return_value=(('link', '<https://api.github.com/repos/frost-nzcr4/find_forks/forks?page=2>; rel="next", '
'<https://api.github.com/repos/frost-nzcr4/find_forks/forks?page=3>; rel="last"'), ))
return response_mock
示例15: test_change_password
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import info [as 别名]
def test_change_password(self):
role = postgres_roles.PostgresRole(MagicMock(), "bw", {
'superuser': False,
'password': "new",
})
status = MagicMock()
status.info = {
'exists': True,
'needs_fixing': ['superuser'],
'password_hash': "old",
'superuser': False,
}
self.assertEqual(
role.ask(status),
"password hash old\n → md5d4011cb5bc2abb087f5ae9d3ca846423",
)