Fix PyYAML warning

Use SafeLoader to get rid of warning.
This commit is contained in:
Grigori Goronzy 2021-01-02 17:22:15 +01:00
parent 77b3f0e1b7
commit 2d7ccf8b3d

View File

@ -137,7 +137,7 @@ class ProgramTests(unittest.TestCase):
def test_program_stc8_untrimmed(self, out, sleep_mock, serial_mock, write_mock, read_mock): def test_program_stc8_untrimmed(self, out, sleep_mock, serial_mock, write_mock, read_mock):
"""Test error with untrimmed MCU""" """Test error with untrimmed MCU"""
with open("./tests/stc8f2k08s2-untrimmed.yml") as test_file: with open("./tests/stc8f2k08s2-untrimmed.yml") as test_file:
test_data = yaml.load(test_file.read()) test_data = yaml.load(test_file.read(), Loader=yaml.SafeLoader)
opts = get_default_opts() opts = get_default_opts()
opts.trim = 0.0 opts.trim = 0.0
opts.protocol = test_data["protocol"] opts.protocol = test_data["protocol"]
@ -154,7 +154,7 @@ class ProgramTests(unittest.TestCase):
def _program_yml(self, yml, serial_mock, read_mock): def _program_yml(self, yml, serial_mock, read_mock):
"""Program MCU with data from YAML file""" """Program MCU with data from YAML file"""
with open(yml) as test_file: with open(yml) as test_file:
test_data = yaml.load(test_file.read()) test_data = yaml.load(test_file.read(), Loader=yaml.SafeLoader)
opts = get_default_opts() opts = get_default_opts()
opts.protocol = test_data["protocol"] opts.protocol = test_data["protocol"]
opts.code_image.read.return_value = bytes(test_data["code_data"]) opts.code_image.read.return_value = bytes(test_data["code_data"])