From e862e78553c7e70c7f4bd79107dc627e88feb266 Mon Sep 17 00:00:00 2001 From: Josef Friedrich Date: Sun, 31 Dec 2023 09:25:19 +0100 Subject: [PATCH] Improve testing --- .vscode/settings.json | 5 ++++- mscxyz/score_file_classes.py | 3 ++- tests/test_score_file_classes.py | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 21d34b5..f567ab9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -59,5 +59,8 @@ }, "python.defaultInterpreterPath": ".venv/bin/python", "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true + "python.testing.pytestEnabled": true, + "python.testing.pytestArgs": [ + "--rootdir", "${workspaceFolder}/tests", + ] } \ No newline at end of file diff --git a/mscxyz/score_file_classes.py b/mscxyz/score_file_classes.py index 6bc5183..1446974 100644 --- a/mscxyz/score_file_classes.py +++ b/mscxyz/score_file_classes.py @@ -10,6 +10,7 @@ MscoreLyricsInterface """ +from __future__ import annotations import fnmatch import os @@ -33,7 +34,7 @@ def list_scores( path: str, extension: str = "both", glob: Optional[str] = None -) -> List[str]: +) -> list[str]: """List all scores in path. :param path: The path so search for score files. diff --git a/tests/test_score_file_classes.py b/tests/test_score_file_classes.py index 443d469..4cd6be5 100644 --- a/tests/test_score_file_classes.py +++ b/tests/test_score_file_classes.py @@ -1,9 +1,13 @@ """Test submodules “score_file_classes.py”""" + +from __future__ import annotations + import filecmp import os import pathlib import shutil +from typing import Optional from unittest import mock import pytest @@ -22,7 +26,9 @@ class TestFunctions: @staticmethod - def _list_scores(path, extension="both", glob=None): + def _list_scores( + path: str, extension: str = "both", glob: Optional[str] = None + ) -> list[str]: with mock.patch("os.walk") as mockwalk: mockwalk.return_value = [ ("/a", ("bar",), ("lorem.mscx",)),