|
1 | | -import io |
2 | 1 | import os |
3 | 2 | import pathlib |
4 | 3 | from dataclasses import dataclass |
@@ -199,43 +198,26 @@ def from_parent( |
199 | 198 | return result |
200 | 199 |
|
201 | 200 | def runtest(self): |
202 | | - from asdf import AsdfFile, _block, generic_io |
| 201 | + import asdf |
| 202 | + from asdf import _block, generic_io |
203 | 203 | from asdf.testing import helpers |
204 | 204 |
|
205 | 205 | # Make sure that the examples in the schema files (and thus the |
206 | 206 | # ASDF standard document) are valid. |
207 | 207 | buff = helpers.yaml_to_asdf("example: " + self.example.example.strip(), version=self.example.version) |
208 | 208 |
|
209 | | - ff = AsdfFile( |
210 | | - uri=pathlib.Path(self.filename).expanduser().absolute().as_uri(), |
211 | | - ignore_unrecognized_tag=self.ignore_unrecognized_tag, |
212 | | - ) |
213 | | - |
214 | | - # Fake an external file |
215 | | - ff2 = AsdfFile({"data": np.empty((1024 * 1024 * 8), dtype=np.uint8)}) |
216 | | - |
217 | | - ff._external_asdf_by_uri[ |
218 | | - (pathlib.Path(self.filename).expanduser().absolute().parent / "external.asdf").as_uri() |
219 | | - ] = ff2 |
220 | | - |
| 209 | + # add a few blocks |
| 210 | + # make a block and write it out to the above generated buffer/example |
221 | 211 | wb = _block.writer.WriteBlock(np.zeros(1024 * 1024 * 8, dtype=np.uint8)) |
222 | 212 | with generic_io.get_file(buff, mode="rw") as f: |
223 | 213 | f.seek(0, 2) |
224 | 214 | _block.writer.write_blocks(f, [wb, wb], streamed_block=wb) |
225 | 215 | f.seek(0) |
226 | 216 |
|
227 | | - try: |
228 | | - ff._open_impl(ff, buff, mode="rw") |
229 | | - except Exception: |
230 | | - print(f"Example: {self.example.description}\n From file: {self.filename}") |
231 | | - raise |
| 217 | + af = asdf.loads(buff.getvalue()) |
232 | 218 |
|
233 | | - # Just test we can write it out. A roundtrip test |
234 | | - # wouldn't always yield the correct result, so those have |
235 | | - # to be covered by "real" unit tests. |
236 | 219 | if b"external.asdf" not in buff.getvalue(): |
237 | | - buff = io.BytesIO() |
238 | | - ff.write_to(buff) |
| 220 | + asdf.dumps(af) |
239 | 221 |
|
240 | 222 | def reportinfo(self): |
241 | 223 | return self.fspath, 0, "" |
|
0 commit comments