Skip to content

Commit ac2c7f7

Browse files
committed
further simplify example checking
1 parent 26e8d46 commit ac2c7f7

1 file changed

Lines changed: 6 additions & 19 deletions

File tree

pytest_asdf/plugin.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import pathlib
33
from dataclasses import dataclass
44

5-
import numpy as np
65
import pytest
76
import yaml
87

@@ -199,25 +198,13 @@ def from_parent(
199198

200199
def runtest(self):
201200
import asdf
202-
from asdf import _block, generic_io
203-
from asdf.testing import helpers
201+
from asdf.testing.helpers import yaml_to_asdf
204202

205-
# Make sure that the examples in the schema files (and thus the
206-
# ASDF standard document) are valid.
207-
buff = helpers.yaml_to_asdf("example: " + self.example.example.strip(), version=self.example.version)
208-
209-
# add a few blocks
210-
# make a block and write it out to the above generated buffer/example
211-
wb = _block.writer.WriteBlock(np.zeros(1024 * 1024 * 8, dtype=np.uint8))
212-
with generic_io.get_file(buff, mode="rw") as f:
213-
f.seek(0, 2)
214-
_block.writer.write_blocks(f, [wb, wb], streamed_block=wb)
215-
f.seek(0)
216-
217-
af = asdf.loads(buff.getvalue())
218-
219-
if b"external.asdf" not in buff.getvalue():
220-
asdf.dumps(af)
203+
# check the example is valid
204+
buff = yaml_to_asdf("example: " + self.example.example.strip(), version=self.example.version)
205+
tagged_tree = asdf.util.load_yaml(buff, tagged=True)
206+
instance = asdf.AsdfFile(version=self.example.version)
207+
asdf.schema.validate(tagged_tree, instance, reading=True)
221208

222209
def reportinfo(self):
223210
return self.fspath, 0, ""

0 commit comments

Comments
 (0)