Fixed tests and reached 100% coverage

This commit is contained in:
Nicolas Margulies 2021-01-10 22:39:52 +01:00
parent 519504fc32
commit f05652d9b8
2 changed files with 2 additions and 15 deletions

View File

@ -120,21 +120,6 @@ class Player(InventoryHolder, FightingEntity):
self.current_xp += int(xp * self.xp_buff)
self.level_up()
def remove_from_inventory(self, obj: Item) -> None:
"""
Remove the given item from the inventory, even if the item is equipped.
"""
if obj == self.equipped_main:
self.equipped_main = None
elif obj == self.equipped_armor:
self.equipped_armor = None
elif obj == self.equipped_secondary:
self.equipped_secondary = None
elif obj == self.equipped_helmet:
self.equipped_helmet = None
else:
return super().remove_from_inventory(obj)
# noinspection PyTypeChecker,PyUnresolvedReferences
def check_move(self, y: int, x: int, move_if_possible: bool = False) \
-> bool:

View File

@ -49,6 +49,7 @@ class TestGame(unittest.TestCase):
# Add items in the inventory to check that it is well loaded
bomb.hold(self.game.player)
sword.hold(self.game.player)
sword.equip()
# Ensure that merchants can be saved
merchant = Merchant()
@ -708,6 +709,7 @@ class TestGame(unittest.TestCase):
self.assertIn(shield, self.game.player.inventory)
self.assertIn(helmet, self.game.player.inventory)
self.assertIn(chestplate, self.game.player.inventory)
self.game.display_actions(DisplayActions.REFRESH)
# Test rings
self.game.player.inventory.clear()