We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2bad99f commit 5f4de22Copy full SHA for 5f4de22
tests/test_examples.py
@@ -1,4 +1,19 @@
1
-def test_simple_service():
2
- from examples.simple_service import test
+import importlib
+import inspect
3
+from pathlib import Path
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()
0 commit comments