Skip to content

Commit d38b429

Browse files
authored
Update test of examples (#140)
1 parent 37231dc commit d38b429

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

tests/test_examples_parse.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import pathlib
22

3-
import pydantic
4-
import yaml
5-
6-
from pdl.pdl_ast import Program
3+
from pdl.pdl_parser import PDLParseError, parse_file
74

85
EXPECTED_INVALID = [
96
pathlib.Path("tests") / "data" / "line" / "hello.pdl",
@@ -20,12 +17,10 @@
2017
def test_valid_programs() -> None:
2118
actual_invalid: set[str] = set()
2219
for yaml_file_name in pathlib.Path(".").glob("**/*.pdl"):
23-
with open(yaml_file_name, "r", encoding="utf-8") as pdl_file:
24-
try:
25-
data = yaml.safe_load(pdl_file)
26-
_ = Program.model_validate(data)
27-
except pydantic.ValidationError:
28-
actual_invalid |= {str(yaml_file_name)}
20+
try:
21+
_ = parse_file(yaml_file_name)
22+
except PDLParseError:
23+
actual_invalid |= {str(yaml_file_name)}
2924
expected_invalid = set(str(p) for p in EXPECTED_INVALID)
3025
unexpected_invalid = sorted(list(actual_invalid - expected_invalid))
3126
assert len(unexpected_invalid) == 0, unexpected_invalid

tests/test_examples_run.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@
3939
pathlib.Path("examples") / "granite" / "single_round_chat.pdl",
4040
pathlib.Path("examples") / "joke" / "Joke.pdl",
4141
pathlib.Path("examples") / "react" / "multi-agent.pdl",
42+
pathlib.Path("examples") / "react" / "wikipedia.pdl",
4243
pathlib.Path("examples") / "talk" / "11-sdg.pdl",
4344
pathlib.Path("examples") / "talk" / "7-chatbot-roles.pdl",
4445
pathlib.Path("examples") / "talk" / "8-tools.pdl",
46+
pathlib.Path("examples") / "talk" / "9-react.pdl",
4547
pathlib.Path("examples") / "teacher" / "teacher.pdl",
4648
pathlib.Path("examples") / "tools" / "calc.pdl",
4749
pathlib.Path("examples") / "tutorial" / "include.pdl",

0 commit comments

Comments
 (0)