mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-08 12:05:14 -06:00
create levels fixture for class; move out of level load test func
This commit is contained in:
@@ -38,9 +38,7 @@ class TestSprites:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sprites(self) -> List[str]:
|
def sprites(self) -> List[str]:
|
||||||
"""
|
"""
|
||||||
Returns a list of absolute paths to sprites found in the images folder.
|
:return: List of absolute paths to Sprite images
|
||||||
|
|
||||||
:return: List of absolute paths to sprites
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -62,8 +60,7 @@ class TestSprites:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def patterns(self) -> List[Pattern]:
|
def patterns(self) -> List[Pattern]:
|
||||||
"""
|
"""
|
||||||
Returns a list of RegEx
|
:return: A list of Pattern objects to test.
|
||||||
:return: A list of Pattern objects
|
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
_patterns = [
|
_patterns = [
|
||||||
@@ -100,17 +97,25 @@ class TestLevels:
|
|||||||
Tests the Level class.
|
Tests the Level class.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test_levels_are_loadable(self):
|
@pytest.fixture
|
||||||
|
def levels(self) -> List[str]:
|
||||||
"""
|
"""
|
||||||
Tests whether or not a level can be loaded.
|
:return: List of paths to Level files
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
from map import Level
|
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
LEVEL_DIR = os.path.join(BASE_DIR, 'resources', 'levels')
|
LEVEL_DIR = os.path.join(BASE_DIR, 'resources', 'levels')
|
||||||
|
|
||||||
levels = [os.path.join(LEVEL_DIR, file) for file in os.listdir(LEVEL_DIR)]
|
levels = [os.path.join(LEVEL_DIR, file) for file in os.listdir(LEVEL_DIR)]
|
||||||
|
|
||||||
|
return levels
|
||||||
|
|
||||||
|
def test_levels_are_loadable(self, levels) -> None:
|
||||||
|
"""
|
||||||
|
Tests whether or not a level can be loaded.
|
||||||
|
"""
|
||||||
|
from map import Level
|
||||||
|
|
||||||
for level in levels:
|
for level in levels:
|
||||||
Level.load_file(2, 3, level)
|
Level.load_file(2, 3, level)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user