Backport fix for tests running with new pyyaml

This commit is contained in:
Neal Gompa 2021-12-15 04:34:06 -05:00
parent 8045190bad
commit 79fa06d5be
2 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,34 @@
From 125dcb28ea30affeec44029d99bee4b130d5fdc8 Mon Sep 17 00:00:00 2001
From: James Falcon <james.falcon@canonical.com>
Date: Mon, 18 Oct 2021 10:20:18 -0500
Subject: [PATCH] Fix unit test broken by pyyaml upgrade (#1071)
PyYAML upgraded from 5.4.1 to 6.0.0. 6.0.0 always requires a `Loader`
arg to `yaml.load()`
---
tests/unittests/test_net_freebsd.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/unittests/test_net_freebsd.py b/tests/unittests/test_net_freebsd.py
index 466d472b84..e339e1324b 100644
--- a/tests/unittests/test_net_freebsd.py
+++ b/tests/unittests/test_net_freebsd.py
@@ -1,8 +1,8 @@
import os
-import yaml
import cloudinit.net
import cloudinit.net.network_state
+from cloudinit import safeyaml
from cloudinit.tests.helpers import (CiTestCase, mock, readResource, dir2dict)
@@ -65,7 +65,7 @@ def test_render_output_has_yaml(self, mock_subp):
entry = {
'yaml': V1,
}
- network_config = yaml.load(entry['yaml'])
+ network_config = safeyaml.load(entry['yaml'])
ns = cloudinit.net.network_state.parse_net_config_data(network_config)
files = self._render_and_read(state=ns)
assert files == {

View File

@ -1,6 +1,6 @@
Name: cloud-init Name: cloud-init
Version: 21.3 Version: 21.3
Release: 2%{?dist} Release: 3%{?dist}
Summary: Cloud instance init scripts Summary: Cloud instance init scripts
License: ASL 2.0 or GPLv3 License: ASL 2.0 or GPLv3
URL: http://launchpad.net/cloud-init URL: http://launchpad.net/cloud-init
@ -22,6 +22,10 @@ Patch3: cloud-init-21.3-no-override-default-network.patch
# Adding default RHEL configuration file # Adding default RHEL configuration file
Patch4: cloud-init-21.3-Adding-RHEL-default-cloud.cfg.patch Patch4: cloud-init-21.3-Adding-RHEL-default-cloud.cfg.patch
# Fix tests with latest pyyaml
# From: https://github.com/canonical/cloud-init/commit/125dcb28ea30affeec44029d99bee4b130d5fdc8
Patch5: cloud-init-21.4-Fix-unit-test-broken-by-pyyaml-upgrade.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: pkgconfig(systemd) BuildRequires: pkgconfig(systemd)
@ -184,6 +188,9 @@ python3 -m pytest tests/unittests
%changelog %changelog
* Wed Dec 15 2021 Neal Gompa <ngompa@fedoraproject.org> - 21.3-3
- Backport fix for tests running with new pyyaml
* Wed Sep 08 2021 Eduardo Otubo <otubo@redhat.com> - 21.3-2 * Wed Sep 08 2021 Eduardo Otubo <otubo@redhat.com> - 21.3-2
- Adding man pages [bz#1952568] - Adding man pages [bz#1952568]