Merge lp:~barryprice/juju-deployer/resolve-yaml-warnings into lp:juju-deployer

Proposed by Barry Price
Status: Merged
Approved by: Barry Price
Approved revision: 219
Merged at revision: 219
Proposed branch: lp:~barryprice/juju-deployer/resolve-yaml-warnings
Merge into: lp:juju-deployer
Diff against target: 75 lines (+21/-5)
2 files modified
deployer/tests/test_config.py (+11/-2)
deployer/tests/test_diff.py (+10/-3)
To merge this branch: bzr merge lp:~barryprice/juju-deployer/resolve-yaml-warnings
Reviewer Review Type Date Requested Status
Benjamin Allot Approve
Canonical IS Reviewers Pending
Review via email: mp+391925@code.launchpad.net

Commit message

Fix yaml.load() deprecation warnings by using SafeLoader, e.g.:

/home/barryprice/juju-deployer/deployer/tests/test_config.py:102: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.

To post a comment you must log in.
Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Benjamin Allot (ballot) wrote :

LGTM.

Using safe_load lose the C binding optimization but is easier to read and maintain.

review: Approve
Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote :

Change successfully merged at revision 219

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'deployer/tests/test_config.py'
--- deployer/tests/test_config.py 2016-05-07 23:48:30 +0000
+++ deployer/tests/test_config.py 2020-10-07 11:37:47 +0000
@@ -3,6 +3,13 @@
3import mock3import mock
4import os4import os
5import tempfile5import tempfile
6
7try:
8 from yaml import CSafeLoader, CSafeDumper
9 SafeLoader, SafeDumper = CSafeLoader, CSafeDumper
10except ImportError:
11 from yaml import SafeLoader
12
6import yaml13import yaml
714
8import six15import six
@@ -98,8 +105,10 @@
98 # openstack.cfg105 # openstack.cfg
99 # includes -> ubuntu_base.cfg includes106 # includes -> ubuntu_base.cfg includes
100 # includes -> openstack_base.cfg107 # includes -> openstack_base.cfg
101 test_conf = yaml.load(open(108 test_conf = yaml.load(
102 os.path.join(self.test_data_dir, "openstack", "openstack.cfg")))109 open(os.path.join(self.test_data_dir, "openstack", "openstack.cfg")),
110 Loader=SafeLoader
111 )
103 includes = [112 includes = [
104 os.path.join(self.test_data_dir, "openstack", "ubuntu_base.cfg"),113 os.path.join(self.test_data_dir, "openstack", "ubuntu_base.cfg"),
105 os.path.join(self.test_data_dir, "openstack", "openstack_base.cfg")114 os.path.join(self.test_data_dir, "openstack", "openstack_base.cfg")
106115
=== modified file 'deployer/tests/test_diff.py'
--- deployer/tests/test_diff.py 2016-12-20 15:10:01 +0000
+++ deployer/tests/test_diff.py 2020-10-07 11:37:47 +0000
@@ -5,6 +5,13 @@
5import shutil5import shutil
6import tempfile6import tempfile
7import unittest7import unittest
8
9try:
10 from yaml import CSafeLoader, CSafeDumper
11 SafeLoader, SafeDumper = CSafeLoader, CSafeDumper
12except ImportError:
13 from yaml import SafeLoader
14
8import yaml15import yaml
916
10from mock import patch, mock_open17from mock import patch, mock_open
@@ -143,7 +150,7 @@
143 edited_config_file = os.path.join(self.get_dir(), 'saved.yaml')150 edited_config_file = os.path.join(self.get_dir(), 'saved.yaml')
144 dpl.save(edited_config_file)151 dpl.save(edited_config_file)
145 # in memory edit yaml content152 # in memory edit yaml content
146 edited_config = yaml.load(open(edited_config_file))153 edited_config = yaml.load(open(edited_config_file), Loader=SafeLoader)
147 edited_config["relations"].remove(154 edited_config["relations"].remove(
148 ['nova-compute:amqp', 'rabbitmq-server:amqp'])155 ['nova-compute:amqp', 'rabbitmq-server:amqp'])
149 edited_config = yaml.dump({'openstack': edited_config})156 edited_config = yaml.dump({'openstack': edited_config})
@@ -168,7 +175,7 @@
168 edited_config_file = os.path.join(self.get_dir(), 'saved.yaml')175 edited_config_file = os.path.join(self.get_dir(), 'saved.yaml')
169 dpl.save(edited_config_file)176 dpl.save(edited_config_file)
170 # in memory edit yaml content177 # in memory edit yaml content
171 edited_config = yaml.load(open(edited_config_file))178 edited_config = yaml.load(open(edited_config_file), Loader=SafeLoader)
172 edited_config["relations"].remove(179 edited_config["relations"].remove(
173 ['ceilometer:identity-service', 'keystone:identity-service'])180 ['ceilometer:identity-service', 'keystone:identity-service'])
174 edited_config = yaml.dump({'openstack': edited_config})181 edited_config = yaml.dump({'openstack': edited_config})
@@ -193,7 +200,7 @@
193 edited_config_file = os.path.join(self.get_dir(), 'saved.yaml')200 edited_config_file = os.path.join(self.get_dir(), 'saved.yaml')
194 dpl.save(edited_config_file)201 dpl.save(edited_config_file)
195 # in memory edit yaml content202 # in memory edit yaml content
196 edited_config = yaml.load(open(edited_config_file))203 edited_config = yaml.load(open(edited_config_file), Loader=SafeLoader)
197 # remove ':name' from service endpoint specification204 # remove ':name' from service endpoint specification
198 for relation in edited_config["relations"]:205 for relation in edited_config["relations"]:
199 relation = [(relation[0] + ":").split(":")[0],206 relation = [(relation[0] + ":").split(":")[0],

Subscribers

People subscribed via source and target branches