amoralej / rpms / python-ddt

Forked from rpms/python-ddt 3 years ago
Clone

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

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