File: test_schema.py

package info (click to toggle)
python-asdf 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,060 kB
  • sloc: python: 24,224; makefile: 123
file content (26 lines) | stat: -rw-r--r-- 635 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import numpy as np
import pytest

import asdf


@pytest.fixture
def software_asdf_file():
    return asdf.AsdfFile({"obj": asdf.tags.core.Software(name="foo", version="0.0.0")})


@pytest.fixture
def ndarray_asdf_file():
    return asdf.AsdfFile({"obj": np.ndarray([1])})


@pytest.fixture(params=["software_asdf_file", "ndarray_asdf_file"])
def asdf_file(request):
    return request.getfixturevalue(request.param)


def test_validate(asdf_file, benchmark):
    # first validate outside the benchmark to incur
    # extension loading, schema caching and other one-time costs
    asdf_file.validate()
    benchmark(asdf_file.validate)