当前位置: 首页>>代码示例>>Python>>正文


Python Mock.attributes方法代码示例

本文整理汇总了Python中unittest.mock.Mock.attributes方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.attributes方法的具体用法?Python Mock.attributes怎么用?Python Mock.attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.mock.Mock的用法示例。


在下文中一共展示了Mock.attributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_volatility

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_volatility(self):
     ship_item = self.ch.type_(type_id=1, attributes={Attribute.drone_capacity: 10})
     ship_holder = Mock(state=State.offline, item=ship_item, _domain=None, spec_set=Ship(1))
     ship_holder.attributes = {Attribute.drone_capacity: 50}
     self.set_ship(ship_holder)
     item = self.ch.type_(type_id=2, attributes={Attribute.volume: 0})
     holder1 = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder1.attributes = {Attribute.volume: 50}
     self.fit.drones.add(holder1)
     self.track_holder(holder1)
     holder2 = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder2.attributes = {Attribute.volume: 30}
     self.fit.drones.add(holder2)
     self.track_holder(holder2)
     self.assertEqual(self.st.dronebay.used, 80)
     self.assertEqual(self.st.dronebay.output, 50)
     holder1.attributes[Attribute.volume] = 10
     ship_holder.attributes[Attribute.drone_capacity] = 60
     self.st._clear_volatile_attrs()
     self.assertEqual(self.st.dronebay.used, 40)
     self.assertEqual(self.st.dronebay.output, 60)
     self.set_ship(None)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: test_mix_usage_zero

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_mix_usage_zero(self):
     # If some holder has zero usage and drone bay error is
     # still raised, check it's not raised for holder with
     # zero usage
     item = self.ch.type_(type_id=1, attributes={Attribute.volume: 0})
     holder1 = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder1.attributes = {Attribute.volume: 100}
     self.fit.drones.add(holder1)
     self.track_holder(holder1)
     holder2 = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder2.attributes = {Attribute.volume: 0}
     self.fit.drones.add(holder2)
     self.track_holder(holder2)
     self.fit.stats.dronebay.used = 100
     self.fit.stats.dronebay.output = 50
     restriction_error1 = self.get_restriction_error(holder1, Restriction.dronebay_volume)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.output, 50)
     self.assertEqual(restriction_error1.total_use, 100)
     self.assertEqual(restriction_error1.holder_use, 100)
     restriction_error2 = self.get_restriction_error(holder2, Restriction.dronebay_volume)
     self.assertIsNone(restriction_error2)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
开发者ID:,项目名称:,代码行数:28,代码来源:

示例3: test_fail_excess_multiple

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_fail_excess_multiple(self):
     # When multiple consumers require less than pg output
     # alone, but in sum want more than total output, it should
     # be erroneous situation
     item = self.ch.type_(type_id=1, attributes={Attribute.power: 0})
     holder1 = Mock(state=State.online, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     holder1.attributes = {Attribute.power: 25}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     holder2.attributes = {Attribute.power: 20}
     self.track_holder(holder2)
     self.fit.stats.powergrid.used = 45
     self.fit.stats.powergrid.output = 40
     restriction_error1 = self.get_restriction_error(holder1, Restriction.powergrid)
     self.assertIsNotNone(restriction_error1)
     self.assertEqual(restriction_error1.output, 40)
     self.assertEqual(restriction_error1.total_use, 45)
     self.assertEqual(restriction_error1.holder_use, 25)
     restriction_error2 = self.get_restriction_error(holder2, Restriction.powergrid)
     self.assertIsNotNone(restriction_error2)
     self.assertEqual(restriction_error2.output, 40)
     self.assertEqual(restriction_error2.total_use, 45)
     self.assertEqual(restriction_error2.holder_use, 20)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
开发者ID:,项目名称:,代码行数:29,代码来源:

示例4: test_use_multiple

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_use_multiple(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.upgrade_cost: 0})
     holder1 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     holder1.attributes = {Attribute.upgrade_cost: 50}
     self.track_holder(holder1)
     holder2 = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     holder2.attributes = {Attribute.upgrade_cost: 30}
     self.track_holder(holder2)
     self.assertEqual(self.st.calibration.used, 80)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:,项目名称:,代码行数:15,代码来源:

示例5: test_use_negative

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_use_negative(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.cpu: 0})
     holder1 = Mock(state=State.online, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     holder1.attributes = {Attribute.cpu: 50}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     holder2.attributes = {Attribute.cpu: -30}
     self.track_holder(holder2)
     self.assertEqual(self.st.cpu.used, 20)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:blitzmann,项目名称:Eos,代码行数:15,代码来源:test_cpu.py

示例6: test_use_other_class_domain

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_use_other_class_domain(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.power: 0})
     holder1 = Mock(state=State.online, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     holder1.attributes = {Attribute.power: 50}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online, item=item, _domain=Domain.character, spec_set=Implant(1))
     holder2.attributes = {Attribute.power: 30}
     self.track_holder(holder2)
     self.assertEqual(self.st.powergrid.used, 80)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:,项目名称:,代码行数:15,代码来源:

示例7: test_use_negative

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_use_negative(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.drone_bandwidth_used: 0})
     holder1 = Mock(state=State.online, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder1.attributes = {Attribute.drone_bandwidth_used: 50}
     self.track_holder(holder1)
     holder2 = Mock(state=State.online, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder2.attributes = {Attribute.drone_bandwidth_used: -30}
     self.track_holder(holder2)
     self.assertEqual(self.st.drone_bandwidth.used, 20)
     self.untrack_holder(holder1)
     self.untrack_holder(holder2)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:blitzmann,项目名称:Eos,代码行数:15,代码来源:test_drone_bandwidth.py

示例8: test_use_single_rounding_down

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_use_single_rounding_down(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.cpu: 0})
     holder = Mock(state=State.online, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     holder.attributes = {Attribute.cpu: 44.4444444444}
     self.track_holder(holder)
     self.assertEqual(self.st.cpu.used, 44.44)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:blitzmann,项目名称:Eos,代码行数:11,代码来源:test_cpu.py

示例9: test_use_single_rounding_up

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_use_single_rounding_up(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.power: 0})
     holder = Mock(state=State.online, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     holder.attributes = {Attribute.power: 55.5555555555}
     self.track_holder(holder)
     self.assertEqual(self.st.powergrid.used, 55.56)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:,项目名称:,代码行数:11,代码来源:

示例10: test_use_single_no_rounding

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_use_single_no_rounding(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.upgrade_cost: 0})
     holder = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=ModuleHigh(1))
     holder.attributes = {Attribute.upgrade_cost: 55.5555555555}
     self.track_holder(holder)
     self.assertEqual(self.st.calibration.used, 55.5555555555)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:,项目名称:,代码行数:11,代码来源:

示例11: test_fail_original

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_fail_original(self):
     # Original value must be taken
     item = self.ch.type_(type_id=1, attributes={Attribute.rig_size: 10})
     holder = Mock(state=State.offline, item=item, _domain=Domain.ship, spec_set=Rig(1))
     holder.attributes = {Attribute.rig_size: 5}
     self.track_holder(holder)
     ship_item = self.ch.type_(type_id=2, attributes={Attribute.rig_size: 6})
     ship_holder = Mock(state=State.offline, item=ship_item, _domain=None, spec_set=Ship(1))
     ship_holder.attributes = {Attribute.rig_size: 5}
     self.set_ship(ship_holder)
     restriction_error = self.get_restriction_error(holder, Restriction.rig_size)
     self.assertIsNotNone(restriction_error)
     self.assertEqual(restriction_error.allowed_size, 6)
     self.assertEqual(restriction_error.holder_size, 10)
     self.untrack_holder(holder)
     self.set_ship(None)
     self.assertEqual(len(self.log), 0)
     self.assert_restriction_buffers_empty()
开发者ID:,项目名称:,代码行数:20,代码来源:

示例12: test_use_single_no_rounding

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_use_single_no_rounding(self):
     item = self.ch.type_(type_id=1, attributes={Attribute.drone_bandwidth_used: 0})
     holder = Mock(state=State.online, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder.attributes = {Attribute.drone_bandwidth_used: 55.5555555555}
     self.track_holder(holder)
     self.assertEqual(self.st.drone_bandwidth.used, 55.5555555555)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:blitzmann,项目名称:Eos,代码行数:11,代码来源:test_drone_bandwidth.py

示例13: test_output_no_attr

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_output_no_attr(self):
     # None for slot amount when no attribute on ship
     ship_item = self.ch.type_(type_id=1)
     ship_holder = Mock(state=State.offline, item=ship_item, _domain=None, spec_set=Ship(1))
     ship_holder.attributes = {}
     self.set_ship(ship_holder)
     self.assertIsNone(self.st.turret_slots.total)
     self.set_ship(None)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:,项目名称:,代码行数:12,代码来源:

示例14: test_output

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_output(self):
     # Check that modified attribute of character is used
     char_item = self.ch.type_(type_id=1, attributes={Attribute.max_active_drones: 2})
     char_holder = Mock(state=State.offline, item=char_item, _domain=None, spec_set=Character(1))
     char_holder.attributes = {Attribute.max_active_drones: 6}
     self.set_character(char_holder)
     self.assertEqual(self.st.launched_drones.total, 6)
     self.set_character(None)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:,项目名称:,代码行数:12,代码来源:

示例15: test_use_other_class

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import attributes [as 别名]
 def test_use_other_class(self):
     # Make sure holders placed to other containers are unaffected
     item = self.ch.type_(type_id=1, attributes={Attribute.volume: 0})
     holder = Mock(state=State.offline, item=item, _domain=Domain.space, spec_set=Drone(1))
     holder.attributes = {Attribute.volume: 30}
     self.fit.rigs.add(holder)
     self.track_holder(holder)
     self.assertEqual(self.st.dronebay.used, 0)
     self.untrack_holder(holder)
     self.assertEqual(len(self.log), 0)
     self.assert_stat_buffers_empty()
开发者ID:,项目名称:,代码行数:13,代码来源:


注:本文中的unittest.mock.Mock.attributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。