mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-11 00:05:22 -06:00
fix using primary instead of secondary for primary sprite holding folders, fix pattern string without comma breaking pattern list, smarter pytest fail statement
This commit is contained in:
@@ -4,10 +4,11 @@ A file dedicated to testing our game and ensuring it can run.
|
|||||||
Integrate this into your IDE's workflow to ensure the game runs from top to bottom.
|
Integrate this into your IDE's workflow to ensure the game runs from top to bottom.
|
||||||
The tests used here should test all of our game's features as best they can.
|
The tests used here should test all of our game's features as best they can.
|
||||||
"""
|
"""
|
||||||
from typing import Pattern, List
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from typing import Pattern, List
|
||||||
|
|
||||||
|
|
||||||
class TestGame:
|
class TestGame:
|
||||||
"""
|
"""
|
||||||
@@ -15,7 +16,7 @@ class TestGame:
|
|||||||
Only tests that it launches and runs for a little bit, not that it is functioning properly.
|
Only tests that it launches and runs for a little bit, not that it is functioning properly.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test_game_runs(self):
|
def test_game_runs(self) -> None:
|
||||||
"""
|
"""
|
||||||
Simply test that the Game runs.
|
Simply test that the Game runs.
|
||||||
"""
|
"""
|
||||||
@@ -50,7 +51,7 @@ class TestSprites:
|
|||||||
for secondary in os.listdir(os.path.join(IMAGE_DIR, primary)):
|
for secondary in os.listdir(os.path.join(IMAGE_DIR, primary)):
|
||||||
secondary = os.path.join(IMAGE_DIR, primary, secondary)
|
secondary = os.path.join(IMAGE_DIR, primary, secondary)
|
||||||
if os.path.isfile(secondary):
|
if os.path.isfile(secondary):
|
||||||
_sprites.append(primary)
|
_sprites.append(secondary)
|
||||||
else:
|
else:
|
||||||
_sprites.extend(
|
_sprites.extend(
|
||||||
os.path.join(secondary, file) for file in
|
os.path.join(secondary, file) for file in
|
||||||
@@ -64,7 +65,7 @@ class TestSprites:
|
|||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
_patterns = [
|
_patterns = [
|
||||||
r'\w+_(?:\w+_)?\d+\.(?:jp(?:eg|e|g)|png)'
|
r'\w+_(?:\w+_)?\d+\.(?:jp(?:eg|e|g)|png)',
|
||||||
r'\w+\d+\.(?:jp(?:eg|e|g)|png)',
|
r'\w+\d+\.(?:jp(?:eg|e|g)|png)',
|
||||||
r'\w+_tile\.(?:jp(?:eg|e|g)|png)'
|
r'\w+_tile\.(?:jp(?:eg|e|g)|png)'
|
||||||
]
|
]
|
||||||
@@ -77,10 +78,10 @@ class TestSprites:
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
for sprite in sprites:
|
for sprite in sprites:
|
||||||
for pattern in patterns:
|
head, tail = os.path.split(sprite)
|
||||||
if pattern.match(os.path.basename(sprite)):
|
if any(pattern.match(tail) is not None for pattern in patterns):
|
||||||
continue
|
continue
|
||||||
pytest.fail(f"Sprite '{sprite}' did not match the schema.")
|
pytest.fail(f"Sprite '{tail}' in '{head}' did not match the schema.")
|
||||||
|
|
||||||
def test_sprite_loads(self, sprites) -> None:
|
def test_sprite_loads(self, sprites) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user