Skip to content

Commit 914f20d

Browse files
author
Sylvain MARIE
committed
Fixed test bugs with pyyaml 6
1 parent 3068e10 commit 914f20d

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

yamlable/tests/test_yamlable.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __exit__(self, exception_type, exception_value, traceback):
2020
pass
2121

2222
import pytest
23-
from yaml import dump, load
23+
from yaml import dump, safe_load
2424

2525
from yamlable import YamlAble, yaml_info
2626

@@ -112,7 +112,7 @@ def close(self):
112112
assert f == Foo.load_yaml(StringIO(y))
113113

114114
# load pyyaml
115-
assert f == load(y)
115+
assert f == safe_load(y)
116116

117117
# mapping, sequences and scalar
118118
y_map = """
@@ -200,7 +200,7 @@ def close(self):
200200
assert f == FooLegacy.load_yaml(StringIO(y))
201201

202202
# load pyyaml
203-
assert f == load(y)
203+
assert f == safe_load(y)
204204

205205
assert enc
206206
assert dec
@@ -262,7 +262,7 @@ def __init__(self, a, b):
262262
"""
263263
assert dump(f, default_flow_style=False) == s
264264

265-
assert dump(load(dump(load(s))), default_flow_style=False) == s
265+
assert dump(safe_load(dump(safe_load(s))), default_flow_style=False) == s
266266

267267

268268
def test_help_yaml_info():
@@ -357,4 +357,4 @@ def close(self):
357357
assert f == FooValid.load_yaml(StringIO(y))
358358

359359
# load pyyaml
360-
assert f == load(y)
360+
assert f == safe_load(y)

yamlable/tests/test_yamlcodec.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
except ImportError:
66
pass
77

8-
from yaml import dump, load
8+
from yaml import dump, safe_load
99

1010
from yamlable import YamlCodec
1111

@@ -86,8 +86,8 @@ def to_yaml_dict(cls, obj):
8686
assert dump(b, default_flow_style=False) == by
8787

8888
# load pyyaml
89-
assert f == load(fy)
90-
assert b == load(by)
89+
assert f == safe_load(fy)
90+
assert b == safe_load(by)
9191

9292
# load from sequence / scalar
9393
by_seq = """!mycodec/yaml.tests.Bar
@@ -96,10 +96,10 @@ def to_yaml_dict(cls, obj):
9696
by_scalar = "!mycodec/yaml.tests.Bar what?"
9797

9898
with pytest.raises(NotImplementedError):
99-
load(by_seq)
99+
safe_load(by_seq)
100100

101101
with pytest.raises(NotImplementedError):
102-
load(by_scalar)
102+
safe_load(by_scalar)
103103

104104
class MyCodec2(MyCodec):
105105
@classmethod
@@ -123,5 +123,5 @@ def from_yaml_scalar(cls,
123123
# register the codec
124124
MyCodec2.register_with_pyyaml()
125125

126-
assert b == load(by_seq)
127-
assert b == load(by_scalar)
126+
assert b == safe_load(by_seq)
127+
assert b == safe_load(by_scalar)

0 commit comments

Comments
 (0)