File: test_asdf.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 (38 lines) | stat: -rw-r--r-- 740 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
27
28
29
30
31
32
33
34
35
36
37
38
import io

import asdf


def test_init(tree, benchmark):
    benchmark(asdf.AsdfFile, tree)


def test_validate(asdf_file, benchmark):
    benchmark(asdf_file.validate)


def test_write_to(asdf_file, benchmark):
    bs = io.BytesIO()
    benchmark(asdf_file.write_to, bs)


def test_open(tree_bytes, benchmark):
    # open doesn't seek to start of file so make a new BytesIO each time
    def asdf_open():
        asdf.open(io.BytesIO(tree_bytes))

    benchmark(asdf_open)


def test_update(tree_bytes, benchmark):
    bs = io.BytesIO(tree_bytes)
    af = asdf.open(bs)
    benchmark(af.update)


def test_dump(tree, benchmark):
    benchmark(asdf.dumps, tree)


def test_load(tree_bytes, benchmark):
    benchmark(asdf.loads, tree_bytes)