mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-16 13:08:25 +00:00
tests: Reuse existing resource enumeration helper
This commit is contained in:
parent
da8cac3264
commit
d2ec953df7
1 changed files with 3 additions and 13 deletions
|
|
@ -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])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue