-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix test suite to correctly regenerate examples across tests
- Loading branch information
1 parent
9c8ece2
commit a490388
Showing
5 changed files
with
37 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import glob | ||
import importlib.util | ||
from pathlib import Path | ||
from types import ModuleType | ||
|
||
EXAMPLES_DIR = Path(__file__).parents[1] / "examples" | ||
|
||
|
||
def build_example(script_path: str) -> ModuleType: | ||
module_name = Path(script_path).stem | ||
spec = importlib.util.spec_from_file_location(module_name, script_path) | ||
if spec is None: | ||
raise ImportError(f"Can't find {script_path}") | ||
module = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(module) | ||
return module | ||
|
||
|
||
def build_examples(examples_dir: Path = EXAMPLES_DIR): | ||
for script_path in glob.glob(str(examples_dir / "*.py")): | ||
_ = build_example(script_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters