-
Notifications
You must be signed in to change notification settings - Fork 0
/
direct.py
42 lines (28 loc) · 955 Bytes
/
direct.py
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 os
import typing
import importlib
import asyncio
import logging
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S", handlers=[logging.StreamHandler()])
async def main():
test_file = os.environ['TEST_FILE']
module = importlib.import_module(test_file)
classes = []
for name in dir(module):
obj = getattr(module, name)
if isinstance(obj, type):
classes.append(obj)
for cls in classes:
print(cls.__name__)
print(cls.__doc__)
print()
inst = cls()
for name in dir(inst):
if isinstance(getattr(inst, name), typing.Callable):
if name.startswith('test_'):
print(name)
getattr(inst, name)()
print()
await getattr(inst, name)()
if __name__ == "__main__":
asyncio.run(main())