diff --git a/kitty_tests/main.py b/kitty_tests/main.py index 78dbf3512..038c340a2 100644 --- a/kitty_tests/main.py +++ b/kitty_tests/main.py @@ -21,23 +21,13 @@ from typing import ( Optional, ) +from kitty.constants import list_kitty_resources + from . import is_ci PARALLEL_THRESHOLD = 20 -def contents(package: str) -> Iterator[str]: - try: - if sys.version_info[:2] < (3, 10): - raise ImportError("importlib.resources.files() doesn't work with frozen builds on python 3.9") - from importlib.resources import files - except ImportError: - from importlib.resources import contents - - return iter(contents(package)) - return (path.name for path in files(package).iterdir()) - - def itertests(suite: unittest.TestSuite) -> Generator[unittest.TestCase, None, None]: stack = [suite] while stack: @@ -55,7 +45,7 @@ def find_all_tests(package: str = '', excludes: Sequence[str] = ('main', 'gr')) suits = [] if not package: package = __name__.rpartition('.')[0] if '.' in __name__ else 'kitty_tests' - for x in sorted(contents(package)): + for x in sorted(list_kitty_resources(package)): name, ext = os.path.splitext(x) if ext in ('.py', '.pyc') and name not in excludes: m = importlib.import_module(package + '.' + x.partition('.')[0])