本文整理汇总了Python中unittest.mock.MagicMock.skipped方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.skipped方法的具体用法?Python MagicMock.skipped怎么用?Python MagicMock.skipped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.skipped方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_correct
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import skipped [as 别名]
def test_correct(self):
status_before = MagicMock()
status_before.correct = True
status_before.skipped = False
item = MockItem(MagicMock(), "item1", {}, skip_validation=True)
item.get_status = MagicMock(return_value=status_before)
item.fix = MagicMock()
result = item.apply()
self.assertFalse(item.fix.called)
self.assertEqual(result, Item.STATUS_OK)
示例2: test_noninteractive
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import skipped [as 别名]
def test_noninteractive(self):
status_before = MagicMock()
status_before.correct = False
status_before.skipped = False
item = MockItem(MagicMock(), "item1", {}, skip_validation=True)
item.get_status = MagicMock(return_value=status_before)
item.fix = MagicMock()
item.apply(interactive=False)
self.assertEqual(item.fix.call_count, 1)
self.assertEqual(item.get_status.call_count, 2)
示例3: test_zero
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import skipped [as 别名]
def test_zero(self):
result = MagicMock()
result.correct = 0
result.fixed = 0
result.skipped = 0
result.failed = 0
self.assertEqual(
format_node_result(result),
"0 OK, 0 fixed, 0 skipped, 0 failed",
)
示例4: test_values
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import skipped [as 别名]
def test_values(self):
result = MagicMock()
result.correct = 0
result.fixed = 1
result.skipped = 2
result.failed = 3
self.assertEqual(
format_node_result(result),
"0 OK, 1 fixed, 2 skipped, 3 failed",
)
示例5: test_interactive
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import skipped [as 别名]
def test_interactive(self, ask_interactively):
status_before = MagicMock()
status_before.correct = False
status_before.fixable = True
status_before.skipped = False
item = MockItem(MagicMock(), "item1", {}, skip_validation=True)
item.get_status = MagicMock(return_value=status_before)
item.ask = MagicMock(return_value="?")
item.fix = MagicMock()
item.apply(interactive=True)
self.assertEqual(item.fix.call_count, 1)
assert ask_interactively.call_count == 1
示例6: test_interactive_abort
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import skipped [as 别名]
def test_interactive_abort(self, ask_interactively):
status_before = MagicMock()
status_before.correct = False
status_before.fixable = True
status_before.skipped = False
item = MockItem(MagicMock(), "item1", {}, skip_validation=True)
item.get_status = MagicMock(return_value=status_before)
item.ask = MagicMock(return_value="?")
item.fix = MagicMock()
result = item.apply(interactive=True)
self.assertFalse(item.fix.called)
assert ask_interactively.call_count == 1
self.assertEqual(result, Item.STATUS_SKIPPED)
示例7: test_unless_fails
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import skipped [as 别名]
def test_unless_fails(self):
status_before = MagicMock()
status_before.correct = False
status_before.skipped = False
item = MockItem(MagicMock(), "item1", {"unless": "false"}, skip_validation=True)
item.get_status = MagicMock(return_value=status_before)
item.fix = MagicMock()
run_result = MagicMock()
run_result.return_code = 1
item.node.run.return_value = run_result
item.apply()
self.assertTrue(item.fix.called)
示例8: test_unless
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import skipped [as 别名]
def test_unless(self):
status_before = MagicMock()
status_before.correct = False
status_before.skipped = False
item = MockItem(MagicMock(), "item1", {"unless": "true"}, skip_validation=True)
item.get_status = MagicMock(return_value=status_before)
item.fix = MagicMock()
run_result = MagicMock()
run_result.return_code = 0
item.node.run.return_value = run_result
result = item.apply()
self.assertFalse(item.fix.called)
self.assertEqual(result, Item.STATUS_SKIPPED)