Blame SOURCES/0001-Use-Yaml-s-UnsafeLoader-for-Python-embedding-tests.patch

rdobuilder 41de67
From 97f0a2315736e50f1b34a015447cd751da66ecb6 Mon Sep 17 00:00:00 2001
rdobuilder 41de67
From: Dirk Mueller <dirk@dmllr.de>
rdobuilder 41de67
Date: Mon, 25 Jan 2021 22:49:04 +0100
rdobuilder 41de67
Subject: [PATCH] Use Yaml's UnsafeLoader for Python embedding tests
rdobuilder 41de67
rdobuilder 41de67
In newer PyYAML versions the default FullLoader has
rdobuilder 41de67
python/object/* integration removed. One has to use
rdobuilder 41de67
UnsafeLoader instead. see this issue for details:
rdobuilder 41de67
rdobuilder 41de67
https://github.com/yaml/pyyaml/issues/321
rdobuilder 41de67
---
rdobuilder 41de67
 test/test_example.py    |  2 +-
rdobuilder 41de67
 test/test_functional.py | 10 +++++-----
rdobuilder 41de67
 2 files changed, 6 insertions(+), 6 deletions(-)
rdobuilder 41de67
rdobuilder 41de67
diff --git a/test/test_example.py b/test/test_example.py
rdobuilder 41de67
index db2cf17..1d27043 100644
rdobuilder 41de67
--- a/test/test_example.py
rdobuilder 41de67
+++ b/test/test_example.py
rdobuilder 41de67
@@ -151,7 +151,7 @@ if have_yaml_support:
rdobuilder 41de67
 
rdobuilder 41de67
     @ddt
rdobuilder 41de67
     class YamlOnlyTestCase(unittest.TestCase):
rdobuilder 41de67
-        @file_data('data/test_custom_yaml_loader.yaml', yaml.FullLoader)
rdobuilder 41de67
+        @file_data('data/test_custom_yaml_loader.yaml', yaml.UnsafeLoader)
rdobuilder 41de67
         def test_custom_yaml_loader(self, instance, expected):
rdobuilder 41de67
             """Test with yaml tags to create specific classes to compare"""
rdobuilder 41de67
             self.assertEqual(expected, instance)
rdobuilder 41de67
diff --git a/test/test_functional.py b/test/test_functional.py
rdobuilder 41de67
index 45c1cae..f9609c6 100644
rdobuilder 41de67
--- a/test/test_functional.py
rdobuilder 41de67
+++ b/test/test_functional.py
rdobuilder 41de67
@@ -440,7 +440,7 @@ def test_load_yaml_with_python_tag():
rdobuilder 41de67
     loader allowing python tags is passed.
rdobuilder 41de67
     """
rdobuilder 41de67
 
rdobuilder 41de67
-    from yaml import FullLoader
rdobuilder 41de67
+    from yaml import UnsafeLoader
rdobuilder 41de67
     from yaml.constructor import ConstructorError
rdobuilder 41de67
 
rdobuilder 41de67
     def str_to_type(class_name):
rdobuilder 41de67
@@ -457,13 +457,13 @@ def test_load_yaml_with_python_tag():
rdobuilder 41de67
             raise AssertionError()
rdobuilder 41de67
 
rdobuilder 41de67
     @ddt
rdobuilder 41de67
-    class YamlFullLoaderTest(object):
rdobuilder 41de67
-        @file_data('data/test_functional_custom_tags.yaml', FullLoader)
rdobuilder 41de67
+    class YamlUnsafeLoaderTest(object):
rdobuilder 41de67
+        @file_data('data/test_functional_custom_tags.yaml', UnsafeLoader)
rdobuilder 41de67
         def test_cls_is_instance(self, instance, expected):
rdobuilder 41de67
             assert isinstance(instance, str_to_type(expected))
rdobuilder 41de67
 
rdobuilder 41de67
-    tests = list(filter(_is_test, YamlFullLoaderTest.__dict__))
rdobuilder 41de67
-    obj = YamlFullLoaderTest()
rdobuilder 41de67
+    tests = list(filter(_is_test, YamlUnsafeLoaderTest.__dict__))
rdobuilder 41de67
+    obj = YamlUnsafeLoaderTest()
rdobuilder 41de67
 
rdobuilder 41de67
     if not tests:
rdobuilder 41de67
         raise AssertionError('No tests have been found.')
rdobuilder 41de67
-- 
rdobuilder 41de67
2.29.2
rdobuilder 41de67