blob: 53c5fc0c3cc0349e81bd3e5dfb7d6c401dded074 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import abc
from . import TestEnvironment
from typing import Dict
class Test:
@abc.abstractmethod
def name(self) -> str:
"""
Name of the test.
"""
def use_device(self) -> bool:
"""
Test uses a specific CPU or GPU device.
"""
return False
@abc.abstractmethod
def run(self, env: TestEnvironment) -> Dict:
"""
Execute the test and report results.
"""
class TestCollection:
def __init__(self, env: TestEnvironment):
import importlib
import pkgutil
import tests
self.tests = []
for _, modname, _ in pkgutil.iter_modules(tests.__path__, 'tests.'):
module = importlib.import_module(modname)
self.tests += module.generate(env)
def find(self, test_name: str):
for test in self.tests:
if test.name() == test_name:
return test
return None
|