Skip to content

Commit 84960ad

Browse files
committed
Updated block display tests to hide tree so that changes in the tree
don't impact snapshot testing
1 parent c805ab3 commit 84960ad

4 files changed

Lines changed: 14 additions & 158 deletions

File tree

Lines changed: 3 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,13 @@
11
# serializer version: 1
22
# name: test_info_blocks_hide
33
'''
4-
root (AsdfObject)
5-
├─asdf_library (Software)
6-
│ ├─author (str): The ASDF Developers
7-
│ ├─homepage (str): http://github.com/asdf-format/asdf
8-
│ ├─name (str): asdf
9-
│ └─version (str): 3.0.0.dev613+g96800153.d20230926
10-
├─history (dict)
11-
│ └─extensions (list)
12-
│ └─[0] (ExtensionMetadata)
13-
│ ├─extension_class (str): asdf.extension._manifest.ManifestExtension
14-
│ ├─extension_uri (str): asdf://asdf-format.org/core/extensions/core-1.5.0
15-
│ └─software (Software)
16-
│ ├─name (str): asdf
17-
│ └─version (str): 3.0.0.dev613+g96800153.d20230926
18-
└─a (NDArrayType)
19-
├─shape (tuple)
20-
│ └─[0] (int): 2
21-
└─dtype (Int64DType): int64
4+
Some nodes not shown.
225

236
'''
247
# ---
258
# name: test_info_blocks_show[ndarray0.asdf]
269
'''
27-
root (AsdfObject)
28-
├─asdf_library (Software)
29-
│ ├─author (str): The ASDF Developers
30-
│ ├─homepage (str): http://github.com/asdf-format/asdf
31-
│ ├─name (str): asdf
32-
│ └─version (str): 3.0.0.dev613+g96800153.d20230926
33-
├─history (dict)
34-
│ └─extensions (list)
35-
│ └─[0] (ExtensionMetadata)
36-
│ ├─extension_class (str): asdf.extension._manifest.ManifestExtension
37-
│ ├─extension_uri (str): asdf://asdf-format.org/core/extensions/core-1.5.0
38-
│ └─software (Software)
39-
│ ├─name (str): asdf
40-
│ └─version (str): 3.0.0.dev613+g96800153.d20230926
41-
└─a (NDArrayType)
42-
├─shape (tuple)
43-
│ └─[0] (int): 2
44-
└─dtype (Int64DType): int64
10+
Some nodes not shown.
4511
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
4612
┃ Block #0 ┃
4713
┣━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
@@ -57,29 +23,6 @@
5723
# ---
5824
# name: test_info_blocks_show[ndarray2.asdf]
5925
'''
60-
root (AsdfObject)
61-
├─asdf_library (Software)
62-
│ ├─author (str): The ASDF Developers
63-
│ ├─homepage (str): http://github.com/asdf-format/asdf
64-
│ ├─name (str): asdf
65-
│ └─version (str): 5.2.0
66-
├─history (dict)
67-
│ └─extensions (list)
68-
│ └─[0] (ExtensionMetadata)
69-
│ ├─extension_class (str): asdf.extension._manifest.ManifestExtension
70-
│ ├─extension_uri (str): asdf://asdf-format.org/core/extensions/core-1.5.0
71-
│ ├─manifest_software (Software)
72-
│ │ ├─name (str): asdf_standard
73-
│ │ └─version (str): 1.5.0
74-
│ └─software (Software) ...
75-
├─a (NDArrayType)
76-
│ ├─shape (tuple)
77-
│ │ └─[0] (int): 2
78-
│ └─dtype (Int64DType): int64
79-
└─b (NDArrayType)
80-
├─shape (tuple)
81-
│ └─[0] (int): 3
82-
└─dtype (Int64DType): int64
8326
Some nodes not shown.
8427
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
8528
┃ Block #0 ┃
@@ -106,23 +49,7 @@
10649
# ---
10750
# name: test_info_blocks_show[simple_inline_array0.asdf]
10851
'''
109-
root (AsdfObject)
110-
├─asdf_library (Software)
111-
│ ├─author (str): Space Telescope Science Institute
112-
│ ├─homepage (str): http://github.com/spacetelescope/asdf
113-
│ ├─name (str): asdf
114-
│ └─version (str): 2.6.1.dev2+gef67341
115-
├─history (dict)
116-
│ └─extensions (list)
117-
│ └─[0] (ExtensionMetadata)
118-
│ ├─extension_class (str): asdf.extension.BuiltinExtension
119-
│ └─software (Software)
120-
│ ├─name (str): asdf
121-
│ └─version (str): 2.6.1.dev2+gef67341
122-
└─array (NDArrayType)
123-
├─shape (tuple)
124-
│ └─[0] (int): 3
125-
└─dtype (Int64DType): int64
52+
Some nodes not shown.
12653

12754
'''
12855
# ---
Lines changed: 4 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,13 @@
11
# serializer version: 1
22
# name: test_info_command_blocks_hide
33
'''
4-
root (AsdfObject)
5-
├─asdf_library (Software)
6-
│ ├─author (str): The ASDF Developers
7-
│ ├─homepage (str): http://github.com/asdf-format/asdf
8-
│ ├─name (str): asdf
9-
│ └─version (str): 3.0.0.dev613+g96800153.d20230926
10-
├─history (dict)
11-
│ └─extensions (list)
12-
│ └─[0] (ExtensionMetadata)
13-
│ ├─extension_class (str): asdf.extension._manifest.ManifestExtension
14-
│ ├─extension_uri (str): asdf://asdf-format.org/core/extensions/core-1.5.0
15-
│ └─software (Software)
16-
│ ├─name (str): asdf
17-
│ └─version (str): 3.0.0.dev613+g96800153.d20230926
18-
└─a (NDArrayType)
19-
├─shape (tuple)
20-
│ └─[0] (int): 2
21-
└─dtype (Int64DType): int64
4+
Some nodes not shown.
225

236
'''
247
# ---
258
# name: test_info_command_blocks_show[ndarray0.asdf]
269
'''
27-
root (AsdfObject)
28-
├─asdf_library (Software)
29-
│ ├─author (str): The ASDF Developers
30-
│ ├─homepage (str): http://github.com/asdf-format/asdf
31-
│ ├─name (str): asdf
32-
│ └─version (str): 3.0.0.dev613+g96800153.d20230926
33-
├─history (dict)
34-
│ └─extensions (list)
35-
│ └─[0] (ExtensionMetadata)
36-
│ ├─extension_class (str): asdf.extension._manifest.ManifestExtension
37-
│ ├─extension_uri (str): asdf://asdf-format.org/core/extensions/core-1.5.0
38-
│ └─software (Software)
39-
│ ├─name (str): asdf
40-
│ └─version (str): 3.0.0.dev613+g96800153.d20230926
41-
└─a (NDArrayType)
42-
├─shape (tuple)
43-
│ └─[0] (int): 2
44-
└─dtype (Int64DType): int64
10+
Some nodes not shown.
4511
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
4612
┃ Block #0 ┃
4713
┣━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
@@ -57,31 +23,7 @@
5723
# ---
5824
# name: test_info_command_blocks_show[ndarray2.asdf]
5925
'''
60-
root (AsdfObject)
61-
├─asdf_library (Software)
62-
│ ├─author (str): The ASDF Developers
63-
│ ├─homepage (str): http://github.com/asdf-format/asdf
64-
│ ├─name (str): asdf
65-
│ └─version (str): 5.2.0
66-
├─history (dict)
67-
│ └─extensions (list)
68-
│ └─[0] (ExtensionMetadata)
69-
│ ├─extension_class (str): asdf.extension._manifest.ManifestExtension
70-
│ ├─extension_uri (str): asdf://asdf-format.org/core/extensions/core-1.5.0
71-
│ ├─manifest_software (Software)
72-
│ │ ├─name (str): asdf_standard
73-
│ │ └─version (str): 1.5.0
74-
│ └─software (Software)
75-
│ ├─name (str): asdf
76-
│ └─version (str): 5.2.0
77-
├─a (NDArrayType)
78-
│ ├─shape (tuple)
79-
│ │ └─[0] (int): 2
80-
│ └─dtype (Int64DType): int64
81-
└─b (NDArrayType)
82-
├─shape (tuple)
83-
│ └─[0] (int): 3
84-
└─dtype (Int64DType): int64
26+
Some nodes not shown.
8527
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
8628
┃ Block #0 ┃
8729
┣━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
@@ -107,23 +49,7 @@
10749
# ---
10850
# name: test_info_command_blocks_show[simple_inline_array0.asdf]
10951
'''
110-
root (AsdfObject)
111-
├─asdf_library (Software)
112-
│ ├─author (str): Space Telescope Science Institute
113-
│ ├─homepage (str): http://github.com/spacetelescope/asdf
114-
│ ├─name (str): asdf
115-
│ └─version (str): 2.6.1.dev2+gef67341
116-
├─history (dict)
117-
│ └─extensions (list)
118-
│ └─[0] (ExtensionMetadata)
119-
│ ├─extension_class (str): asdf.extension.BuiltinExtension
120-
│ └─software (Software)
121-
│ ├─name (str): asdf
122-
│ └─version (str): 2.6.1.dev2+gef67341
123-
└─array (NDArrayType)
124-
├─shape (tuple)
125-
│ └─[0] (int): 3
126-
└─dtype (Int64DType): int64
52+
Some nodes not shown.
12753

12854
'''
12955
# ---

asdf/_tests/commands/test_info.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def test_info_command_blocks_show(capsys, test_data_path, filename, snapshot):
2828
"""Verify block output for files with different numbers and types of blocks."""
2929

3030
file_path = test_data_path / filename
31-
assert main.main_from_args(["info", "--show-blocks", str(file_path)]) == 0
31+
# Set max_rows to zero to ignore any changes in tree formatting when computing snapshots
32+
assert main.main_from_args(["info", "--max-rows=0", "--show-blocks", str(file_path)]) == 0
3233
captured = capsys.readouterr()
3334
# Run `pytest --snapshot-update` to update stored snapshot
3435
assert captured.out == snapshot
@@ -38,7 +39,8 @@ def test_info_command_blocks_hide(capsys, test_data_path, snapshot):
3839
"""Verify no block output is shown by default when the file contains blocks."""
3940

4041
file_path = test_data_path / "ndarray0.asdf"
41-
assert main.main_from_args(["info", str(file_path)]) == 0
42+
# Set max_rows to zero to ignore any changes in tree formatting when computing snapshots
43+
assert main.main_from_args(["info", "--max-rows=0", str(file_path)]) == 0
4244
captured = capsys.readouterr()
4345
# Run `pytest --snapshot-update` to update stored snapshot
4446
assert captured.out == snapshot

asdf/_tests/test_info.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,10 +839,11 @@ def _get_block_output(capsys, af, *args, **kwargs) -> str:
839839
840840
Returns the unified captured output.
841841
"""
842-
af.info(*args, **kwargs)
842+
# Set max_rows to zero to ignore any changes in tree formatting when computing snapshots
843+
af.info(*args, max_rows=0, **kwargs)
843844
method_cap = capsys.readouterr()
844845

845-
asdf.info(af, *args, **kwargs)
846+
asdf.info(af, *args, max_rows=0, **kwargs)
846847
mod_cap = capsys.readouterr()
847848

848849
assert method_cap.out == mod_cap.out, "AsdfFile.info and asdf.info outputs do not match"

0 commit comments

Comments
 (0)