From 66d54ba4cba5865578043b08cb172b1f3bb50ab3 Mon Sep 17 00:00:00 2001 From: Lukas Bischofberger Date: Fri, 3 Jan 2020 14:44:52 +0100 Subject: [PATCH 1/2] python: fix YAMLLoadWarning --- python/lib/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/lib/util.py b/python/lib/util.py index 30699c261f..53c4ac0518 100644 --- a/python/lib/util.py +++ b/python/lib/util.py @@ -100,7 +100,7 @@ def load_yaml_file(file_path): """ try: with open(file_path) as f: - return yaml.load(f) + return yaml.load(f, Loader=yaml.FullLoader) except OSError as e: raise SCIONIOError("Error opening '%s': %s" % (file_path, e.strerror)) from None From 7cea43831abc1e8163f358db31af609714722479 Mon Sep 17 00:00:00 2001 From: Lukas Bischofberger Date: Fri, 3 Jan 2020 15:20:37 +0100 Subject: [PATCH 2/2] remove test --- python/lib/util.py | 2 +- python/test/lib/util_test.py | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/python/lib/util.py b/python/lib/util.py index 53c4ac0518..3ad39c765d 100644 --- a/python/lib/util.py +++ b/python/lib/util.py @@ -100,7 +100,7 @@ def load_yaml_file(file_path): """ try: with open(file_path) as f: - return yaml.load(f, Loader=yaml.FullLoader) + return yaml.load(f, Loader=yaml.SafeLoader) except OSError as e: raise SCIONIOError("Error opening '%s': %s" % (file_path, e.strerror)) from None diff --git a/python/test/lib/util_test.py b/python/test/lib/util_test.py index 0fb6904449..3d6f329da7 100644 --- a/python/test/lib/util_test.py +++ b/python/test/lib/util_test.py @@ -102,13 +102,6 @@ class Loader(object): """ Helper class for load_yaml_file tests. """ - def _basic(self, target, loader): - loader.return_value = "loader dict" - with patch.object(builtins, 'open', mock_open()) as open_: - ntools.eq_(target("File_Path"), "loader dict") - open_.assert_called_once_with("File_Path") - loader.assert_called_once_with(open_.return_value) - @patch.object(builtins, 'open', mock_open()) def _file_error(self, target): builtins.open.side_effect = IsADirectoryError @@ -125,10 +118,6 @@ class TestLoadYAMLFile(Loader): """ Unit tests for lib.util.load_yaml_file """ - @patch("lib.util.yaml.load", autospec=True) - def test_basic(self, loader): - self._basic(load_yaml_file, loader) - def test_file_error(self): self._file_error(load_yaml_file)