Skip to content

Commit 1b96816

Browse files
committed
resolve conversation
1 parent 604b20b commit 1b96816

1 file changed

Lines changed: 24 additions & 34 deletions

File tree

tests/test_hyperyaml.py

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -179,44 +179,34 @@ def test_load_hyperpyyaml(tmpdir):
179179

180180
# Applyref tag
181181
yaml = """
182-
a: 1
183-
b: 2
184-
c: !applyref:sum [[!ref <a>, !ref <b>]]
182+
c: !applyref:sorted
183+
_args:
184+
- [3, 4, 1, 2]
185+
_kwargs:
186+
reverse: False
185187
d: !ref <c>-<c>
186-
"""
187-
things = load_hyperpyyaml(yaml)
188-
assert things["d"] == 0
189188
190-
# Applyref method
191-
yaml = """
192-
a: "A STRING"
193-
common_kwargs:
194-
thing1: !ref <a.lower>
195-
thing2: 2
196-
c: !applyref:hyperpyyaml.TestThing.from_keys
197-
args:
198-
- 1
199-
- 2
200-
kwargs: !ref <common_kwargs>
201-
"""
202-
things = load_hyperpyyaml(yaml)
203-
assert things["c"][:12] == "<hyperpyyaml"
204-
205-
yaml = """
206-
a: "A STRING"
207-
common_kwargs:
208-
thing1: !ref <a.lower>
209-
thing2: 2
210-
c: !applyref:hyperpyyaml.TestThing.from_keys
211-
_args: []
212-
_kwargs:
213-
args:
214-
- 1
215-
- 2
216-
kwargs: !ref <common_kwargs>
189+
# 2. Only pass the keyword arguments
190+
e: !applyref:random.randint
191+
a: 1
192+
b: 3
193+
f: !ref <e><e>
194+
195+
# 3. Only pass the positional arguments
196+
g: !applyref:random.randint
197+
- 1
198+
- 3
199+
h: !ref <g><g>
200+
201+
# 4. No arguments
202+
i: !applyref:random.random
203+
j: !ref <i>
217204
"""
218205
things = load_hyperpyyaml(yaml)
219-
assert things["c"][:12] == "<hyperpyyaml"
206+
assert things["d"] == "[1, 2, 3, 4]-[1, 2, 3, 4]"
207+
assert things["f"] in [11, 22, 33]
208+
assert things["h"] in [11, 22, 33]
209+
assert things["j"] < 1 and things["j"] >= 0
220210

221211
# Refattr:
222212
yaml = """

0 commit comments

Comments
 (0)