diff --git a/README.md b/README.md index d2d4444..3b68e3c 100644 --- a/README.md +++ b/README.md @@ -29,4 +29,4 @@ If the level is left out, it will be `logging.DEBUG` or `logging.WARNING`, depen ## Testing -Testing has to be done locally as the GitHub remote is running headless. Now with the transition to arcade 3 excluding the `requires_window` mark doesn't work either anymore. +Despite having an action for testing, GitHub Actions is running headless so some functions (with the `requires_window` mark) won't run there, requiring local testing before every merge as well. diff --git a/cme/resource_/assets.py b/cme/resource_/assets.py index 30c5e27..3460641 100644 --- a/cme/resource_/assets.py +++ b/cme/resource_/assets.py @@ -21,13 +21,13 @@ class AssetsPath(type(Path())): # type: ignore Subclass or instantiate this to create a hierarchie of assets folders (e.g. `ImagesPath`, `SoundsPath`, ...). """ - def __new__(cls, *pathsegments: str | Path) -> AssetsPath: - return super().__new__(cls, *pathsegments) # type: ignore + obj: AssetsPath = super().__new__(cls, *pathsegments) + obj.get = obj.find_asset + return obj - def __init__(self, *args: Any) -> None: - super().__init__(*args) - self.get = self.find_asset + # Avoiding using an __init__ because it doesn't work really well with the + # pathlib Path system def find_asset( self, diff --git a/tests/conftest.py b/tests/conftest.py index a1fa6cb..2a9ff6d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,7 +10,6 @@ from cme import init_cme # noqa -@pytest.mark.requires_window @pytest.fixture(scope="session") def initialize_window() -> Generator[arcade.Window, None, None]: window = arcade.Window() diff --git a/tests/test_logger/test_logger.py b/tests/test_logger/test_logger.py index 444458a..cee2f85 100644 --- a/tests/test_logger/test_logger.py +++ b/tests/test_logger/test_logger.py @@ -1,6 +1,6 @@ import atexit import logging -import os +import shutil from pathlib import Path from tempfile import mkdtemp @@ -25,4 +25,8 @@ def test_logger_functions() -> None: logger.error("Error") logger.critical("Critical") - atexit.register(lambda: os.unlink(tempdir)) + def cleanup_logger() -> None: + logging.shutdown() + shutil.rmtree(tempdir) + + atexit.register(cleanup_logger) diff --git a/tests/test_utils/test_utils.py b/tests/test_utils/test_utils.py index f7b980d..6737046 100644 --- a/tests/test_utils/test_utils.py +++ b/tests/test_utils/test_utils.py @@ -8,12 +8,12 @@ def test_get_optimal_font_size(initialize_window: None) -> None: input_args = [ ("Hello World!", "Times New Roman", 64, 96), ("This is part of our amazing test suite", "Calibri", 12345, 67890), - ("Sage, the life you give... Have you ever wondered where it's taken from?", "Comic Sans MS", 1000, 200), # noqa + ("Sage, the life you give... Have you ever wondered where it's taken from?", "Arial", 1000, 200), # noqa ] expected_output = [ 9, 512, - 29, + 23, ] for ( (text, font_name, container_width, container_height), expected