本文整理汇总了Python中unittest.mock.Mock.__class__方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.__class__方法的具体用法?Python Mock.__class__怎么用?Python Mock.__class__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.Mock
的用法示例。
在下文中一共展示了Mock.__class__方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getSprintNegativeInput
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import __class__ [as 别名]
def test_getSprintNegativeInput(self):
# Make sure IBacklog.getSprint returns [] for negative totalPointsAchievable input.
storylist = self._getFakeStoryList1()
datastore_mock = Mock()
datastore_mock.__class__ = IDatastore
datastore_mock.readStory.return_value = storylist
backlog = IBacklog(datastore_mock)
actual_storylist = backlog.getSprint(-1)
self.assertEqual(actual_storylist, [])
示例2: test_Add
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import __class__ [as 别名]
def test_Add(self):
# Make sure datastore.createStory is called once when IBacklog.Add is called.
story1 = Story("1", 3, 1)
datastore_mock = Mock()
datastore_mock.__class__ = IDatastore
datastore_mock.createStory(story1)
datastore_mock.createStory.assert_called_once_with(story1)
backlog = IBacklog(datastore_mock)
backlog.Add(story1)
示例3: test_getSprintExpectAllStories
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import __class__ [as 别名]
def test_getSprintExpectAllStories(self):
# Make sure IBacklog.getSprint returns all the stories when totalPointsAchievable input
# is greater than the total points of all the stories.
storylist = self._getFakeStoryList1()
datastore_mock = Mock()
datastore_mock.__class__ = IDatastore
datastore_mock.readStory.return_value = storylist
backlog = IBacklog(datastore_mock)
actual_storylist= backlog.getSprint(46)
self.assertEqual(storylist, actual_storylist)
示例4: test_RemoveRaisesException
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import __class__ [as 别名]
def test_RemoveRaisesException(self):
# Make sure an exception is raised IBacklog.Remove is called with the Id of a story
# that is not in the datastore.
datastore_mock = Mock()
datastore_mock.__class__ = IDatastore
datastore_mock.deleteStory.return_value = None
datastore_mock.deleteStory("1")
datastore_mock.deleteStory.assert_called_once_with("1")
backlog = IBacklog(datastore_mock)
self.assertRaises(StoryNotFoundError, backlog.Remove, "1")
示例5: test_getSprintAllPointsTooHigh
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import __class__ [as 别名]
def test_getSprintAllPointsTooHigh(self):
# Make sure IBacklog.getSprint returns [] when all stories have Point value higher than
# totalPointsAchievable input.
story1 = Story("1", 2, 1)
story2 = Story("2", 3, 1)
story3 = Story("3", 4, 1)
storylist = [story1, story2, story3]
datastore_mock = Mock()
datastore_mock.__class__ = IDatastore
datastore_mock.readStory.return_value = storylist
backlog = IBacklog(datastore_mock)
actual_storylist = backlog.getSprint(1)
self.assertEqual(actual_storylist, [])
示例6: test_Remove
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import __class__ [as 别名]
def test_Remove(self):
# Make sure datastore.deleteStory is called once when IBacklog.Remove is called.
# Make sure the story is returned.
story1 = Story("1", 3, 1)
datastore_mock = Mock()
datastore_mock.__class__ = IDatastore
datastore_mock.deleteStory.return_value = story1
datastore_mock.deleteStory("1")
datastore_mock.deleteStory.assert_called_once_with("1")
backlog = IBacklog(datastore_mock)
actual_story = backlog.Remove("1")
self.assertEqual(actual_story, story1)
示例7: test_getSprintSamePriority
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import __class__ [as 别名]
def test_getSprintSamePriority(self):
# Make sure IBacklog.getSprint maximizes Points when all stories are the same Priority.
story1 = Story("1", 1, 1)
story2 = Story("2", 1, 1)
story3 = Story("3", 3, 1)
storylist = [story1, story2, story3]
datastore_mock = Mock()
datastore_mock.__class__ = IDatastore
datastore_mock.readStory.return_value = storylist
backlog = IBacklog(datastore_mock)
actual_storylist = backlog.getSprint(3)
self.assertIn(story3, actual_storylist)
self.assertNotIn(story1, actual_storylist)
self.assertNotIn(story2, actual_storylist)
示例8: test_getSprintNormal1
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import __class__ [as 别名]
def test_getSprintNormal1(self):
# Make sure IBacklog.getSprint returns the maximum stories for totalPointsAchievable input.
# Lower Priority number is more important.
# Maximize lower Priority first, than higher Priorities.
storylist = self._getFakeStoryList1()
datastore_mock = Mock()
datastore_mock.__class__ = IDatastore
datastore_mock.readStory.return_value = storylist
backlog = IBacklog(datastore_mock)
actual_storylist = backlog.getSprint(10)
self.assertIn(self.story1, actual_storylist)
self.assertIn(self.story3, actual_storylist)
self.assertIn(self.story6, actual_storylist)
self.assertNotIn(self.story2, actual_storylist)
self.assertNotIn(self.story4, actual_storylist)
self.assertNotIn(self.story5, actual_storylist)