2020-12-26 19:07:45 +01:00
|
|
|
import glob
|
|
|
|
import importlib
|
|
|
|
import inspect
|
|
|
|
import pytest
|
2023-03-07 02:02:07 +01:00
|
|
|
import pprint
|
|
|
|
import json
|
2020-12-26 19:07:45 +01:00
|
|
|
|
|
|
|
def discover_app_constructors():
|
|
|
|
apps = []
|
2023-03-07 02:02:07 +01:00
|
|
|
appClasses = []
|
2020-12-26 19:07:45 +01:00
|
|
|
|
2023-03-07 02:02:07 +01:00
|
|
|
globs_system = glob.glob('wasp/apps/system/*.py')
|
2021-10-03 19:21:52 +02:00
|
|
|
names_system = [ g[5:-3].replace('/', '.') for g in globs_system ]
|
|
|
|
globs_user = glob.glob('apps/*.py')
|
|
|
|
names_user = [ g[:-3].replace('/', '.') for g in globs_user ]
|
2023-03-07 02:02:07 +01:00
|
|
|
globs_watchface = glob.glob('watch_faces/*.py')
|
|
|
|
names_watchface = [ g[:-3].replace('/', '.') for g in globs_watchface ]
|
|
|
|
modules = [ importlib.import_module(n) for n in names_system + names_user + names_watchface ]
|
2020-12-26 19:07:45 +01:00
|
|
|
|
|
|
|
for m in modules:
|
|
|
|
for sym in m.__dict__.keys():
|
2023-03-07 02:02:07 +01:00
|
|
|
if len(sym) > 3 and sym[-3:] == 'App' and not sym in appClasses:
|
2020-12-26 19:07:45 +01:00
|
|
|
constructor = m.__dict__[sym]
|
|
|
|
sig = inspect.signature(constructor)
|
|
|
|
if len(sig.parameters) == 0:
|
|
|
|
apps.append(constructor)
|
2023-03-07 02:02:07 +01:00
|
|
|
appClasses.append(sym)
|
2020-12-26 19:07:45 +01:00
|
|
|
|
|
|
|
return apps
|
|
|
|
|
|
|
|
def pytest_generate_tests(metafunc):
|
|
|
|
if 'constructor' in metafunc.fixturenames:
|
|
|
|
metafunc.parametrize('constructor', discover_app_constructors())
|