File: test_1715.py

package info (click to toggle)
python-asdf 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 7,032 kB
  • sloc: python: 24,068; makefile: 123
file content (25 lines) | stat: -rw-r--r-- 584 bytes parent folder | download | duplicates (3)
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
import asdf


def test_id_in_tree_breaks_ref(tmp_path):
    """
    a dict containing id will break contained References

    https://github.com/asdf-format/asdf/issues/1715
    """
    external_fn = tmp_path / "external.asdf"

    external_tree = {"thing": 42}

    asdf.AsdfFile(external_tree).write_to(external_fn)

    main_fn = tmp_path / "main.asdf"

    af = asdf.AsdfFile({})
    af["id"] = "bogus"
    af["myref"] = {"$ref": "external.asdf#/thing"}
    af.write_to(main_fn)

    with asdf.open(main_fn) as af:
        af.resolve_references()
        assert af["myref"] == 42