File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 1
- def test_simple_service ():
2
- from examples .simple_service import test
1
+ import importlib
2
+ import inspect
3
+ from pathlib import Path
3
4
4
- test .test_main ()
5
+ PROJECT_DIR = Path (__file__ ).parent .parent
6
+ EXAMPLE_DIR = PROJECT_DIR / "examples"
7
+
8
+
9
+ def pytest_generate_tests (metafunc ):
10
+ if "example_name" in metafunc .fixturenames :
11
+ metafunc .parametrize ("example_name" , [item .name for item in EXAMPLE_DIR .glob ("*" ) if item .is_dir ()])
12
+
13
+
14
+ def test_example (example_name : str ):
15
+ test_module = importlib .import_module (f"examples.{ example_name } .test" )
16
+ test_functions = inspect .getmembers (test_module , lambda x : inspect .isfunction (x ) and x .__name__ .startswith ("test_" ))
17
+
18
+ for _name , func in test_functions :
19
+ func ()
You can’t perform that action at this time.
0 commit comments