| 8 | |
| 9 | |
| 10 | class TestExample(TestCase): |
| 11 | def setUp(self) -> None: |
| 12 | new_dir("image") |
| 13 | |
| 14 | def test_run(self) -> None: |
| 15 | """运行所有示例脚本 |
| 16 | |
| 17 | 脚本在 example 目录,通过切换工作目录让图片输出到 image 目录。 |
| 18 | 注意 import_module 只会按 sys.path 的内容去查找模块,不受切换工作目录的影响。 |
| 19 | """ |
| 20 | names = [filepath.stem for filepath in Path("example").glob("*.py")] |
| 21 | with chdir_context("image"): |
| 22 | for name in names: |
| 23 | if name not in {"clabel", "river", "nerv_style"}: |
| 24 | try: |
| 25 | import_module(f"example.{name}") |
| 26 | logger.info(name) |
| 27 | except Exception: |
| 28 | logger.exception(name) |
nothing calls this directly
no outgoing calls
no test coverage detected