URL: https://github.com/freeipa/freeipa/pull/6132
Author: miskopo
 Title: #6132: ipatests: webui: Use YAML loader depending on package version
Action: opened

PR body:
"""
FullLoader class for YAML loader was deprecated in version 5.1 which
also deprecated default loader. Use correct loader based on the pyYAML
package version.

Related: https://pagure.io/freeipa/issue/9009

Signed-off-by: Michal Polovka <mpolo...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/6132/head:pr6132
git checkout pr6132
From d2801544cb974c52988adc30334261089ffaaef8 Mon Sep 17 00:00:00 2001
From: Michal Polovka <mpolo...@redhat.com>
Date: Fri, 7 Jan 2022 12:12:26 +0100
Subject: [PATCH] ipatests: webui: Use YAML loader depending on package version

FullLoader class for YAML loader was deprecated in version 5.1 which
also deprecated default loader. Use correct loader based on the pyYAML
package version.

Related: https://pagure.io/freeipa/issue/9009

Signed-off-by: Michal Polovka <mpolo...@redhat.com>
---
 ipatests/test_webui/ui_driver.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index 20361e4ddda..41fe1af1da1 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -191,7 +191,13 @@ def load_config(cls):
         if not NO_YAML and os.path.isfile(path):
             try:
                 with open(path, 'r') as conf:
-                    cls.config = yaml.load(stream=conf, Loader=yaml.FullLoader)
+                    # FullLoader was introduced in version 5.1.0
+                    # https://pyyaml.org/wiki/PyYAML#history
+                    if yaml.__version__ >= '5.1.0':
+                        cls.config = yaml.load(stream=conf, Loader=yaml.FullLoader)
+                    else:
+                        # use default loader in older versions of pyYAML
+                        cls.config = yaml.load(stream=conf)
             except yaml.YAMLError as e:
                 pytest.skip("Invalid Web UI config.\n%s" % e)
             except IOError as e:
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to