-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56792de
commit dc86371
Showing
2 changed files
with
78 additions
and
37 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,28 @@ | ||
""" | ||
Test that all the examples are valid instances of the schema. | ||
Run with ``python3 -m pytest `` | ||
""" | ||
import pathlib | ||
import json | ||
|
||
import pytest | ||
import jsonschema | ||
from ruamel.yaml import YAML | ||
|
||
|
||
@pytest.mark.parametrize("yaml_path", map(str, pathlib.Path("examples/").glob("*.yml"))) | ||
def test_examples(yaml_path): | ||
yaml = YAML(typ="safe") | ||
with open("demes-specification.yaml") as source: | ||
schema = yaml.load(source) | ||
with open(yaml_path) as source: | ||
data = yaml.load(source) | ||
jsonschema.validate(instance=data, schema=schema) | ||
|
||
# json_path = yaml_path.parent / yaml_path.with_suffix(".resolved.json") | ||
# with open(json_path) as source: | ||
# json_data = json.load(source) | ||
# # Note: we'll probably need to do something less strict here. | ||
# assert json_data == graph_data | ||
|