Skip to content

Commit 3b22987

Browse files
committed
More tests working
1 parent a49c4e1 commit 3b22987

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/test_gameLogic.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
([b'd', 0, b'a', b'w', b'w'], "lowBar", 5),
1414
]
1515
# Tests collision with obstacle
16+
# There is a problem in the test
17+
# Does not take into account the fact that obstacles are destroyed when shapeType stack is empty
18+
# Object is destroyed before it can be registered to hit
19+
# This is due to high speeds used in the tests
20+
# Maybe check hit before moving objects?
1621
@pytest.mark.parametrize("actions, obstacleType, speed", hitTestCases)
1722
def test_Hit(actions, obstacleType, speed):
1823
# Initialize game
@@ -180,11 +185,13 @@ def test_Keyboard():
180185
(0.05)
181186
]
182187
# Test that idle function moves objects and registeres hits correctly
188+
# Here problem is that obstacles list is not a copy of the state.obstacles after initialization, it is still a reference
189+
# Hence stage.obstacles = obstacles
183190
@pytest.mark.parametrize("speed", idleTestCases)
184191
def test_Idle(speed):
185192
gameState = gameStateClass(speed, "test")
186193
# Objects should move
187-
obstacles = gameState.stage.obstacles
194+
obstacles = gameState.stage.obstacles.copy()
188195
gameState.idle()
189196
for i in range(0, len(obstacles)):
190197
assert(obstacles[i].z == gameState.stage.obstacles[i].z - speed)

0 commit comments

Comments
 (0)