Fix broken tests

This commit is contained in:
Yohann D'ANELLO 2020-12-04 17:15:41 +01:00
parent 27fd73c96b
commit 5b4dc601bc
2 changed files with 12 additions and 11 deletions

View File

@ -97,12 +97,13 @@ class TestEntities(unittest.TestCase):
self.assertFalse(item.held) self.assertFalse(item.held)
item.hold(self.player) item.hold(self.player)
self.assertTrue(item.held) self.assertTrue(item.held)
item.drop(2, 6) item.drop()
self.assertEqual(item.y, 2) self.assertEqual(item.y, 1)
self.assertEqual(item.x, 6) self.assertEqual(item.x, 6)
# Pick up item # Pick up item
self.player.move_down() self.player.move_left()
self.player.move_right()
self.assertTrue(item.held) self.assertTrue(item.held)
self.assertEqual(item.held_by, self.player) self.assertEqual(item.held_by, self.player)
self.assertIn(item, self.player.inventory) self.assertIn(item, self.player.inventory)
@ -125,9 +126,13 @@ class TestEntities(unittest.TestCase):
item.act(self.map) item.act(self.map)
self.assertFalse(hedgehog.dead) self.assertFalse(hedgehog.dead)
self.assertFalse(teddy_bear.dead) self.assertFalse(teddy_bear.dead)
item.drop(42, 42) self.player.move(42, 42)
item.hold(self.player)
item.use()
self.assertEqual(item.y, 42) self.assertEqual(item.y, 42)
self.assertEqual(item.x, 42) self.assertEqual(item.x, 42)
# Wait for the explosion
for ignored in range(5):
item.act(self.map) item.act(self.map)
self.assertTrue(hedgehog.dead) self.assertTrue(hedgehog.dead)
self.assertTrue(teddy_bear.dead) self.assertTrue(teddy_bear.dead)

View File

@ -261,11 +261,7 @@ class TestGame(unittest.TestCase):
self.assertEqual(self.game.settings.KEY_LEFT_PRIMARY, 'a') self.assertEqual(self.game.settings.KEY_LEFT_PRIMARY, 'a')
# Navigate to "texture pack" # Navigate to "texture pack"
self.game.handle_key_pressed(KeyValues.DOWN) for ignored in range(9):
self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN) self.game.handle_key_pressed(KeyValues.DOWN)
# Change texture pack # Change texture pack