commit:     3fbd123196e706039c68658e3d4391e16dfde4e0
Author:     Petr Vaněk <arkamar <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 28 14:43:09 2024 +0000
Commit:     Petr Vaněk <arkamar <AT> gentoo <DOT> org>
CommitDate: Fri Jun 28 14:52:24 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3fbd1231

dev-python/pykwalify: fix tests with >=dev-python/ruamel-yaml-1.18

This commit backports upstream patch wich fixes test failures with
>=dev-python/ruamel-yaml-1.18.

Closes: https://bugs.gentoo.org/923136
Signed-off-by: Petr Vaněk <arkamar <AT> gentoo.org>

 .../files/pykwalify-1.8.0-ruamel-yaml-1.18.patch   | 90 ++++++++++++++++++++++
 dev-python/pykwalify/pykwalify-1.8.0-r3.ebuild     |  4 +-
 2 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/dev-python/pykwalify/files/pykwalify-1.8.0-ruamel-yaml-1.18.patch 
b/dev-python/pykwalify/files/pykwalify-1.8.0-ruamel-yaml-1.18.patch
new file mode 100644
index 000000000000..d3e5cd65f6ee
--- /dev/null
+++ b/dev-python/pykwalify/files/pykwalify-1.8.0-ruamel-yaml-1.18.patch
@@ -0,0 +1,90 @@
+From 57bb2ba5c28b6928edb3f07ef581a5a807524baf Mon Sep 17 00:00:00 2001
+From: Lily Foster <[email protected]>
+Date: Sat, 20 Jan 2024 21:14:16 -0500
+Subject: [PATCH] Fixing tests for ruamel yaml 0.18+
+
+Upstream-Issue: https://github.com/Grokzen/pykwalify/issues/198
+Upstream-PR: https://github.com/Grokzen/pykwalify/pull/199
+
+diff --git a/tests/test_core.py b/tests/test_core.py
+index cc84f3e..43271d4 100644
+--- a/tests/test_core.py
++++ b/tests/test_core.py
+@@ -12,7 +12,7 @@
+ 
+ # 3rd party imports
+ import pytest
+-from pykwalify.compat import yaml
++from pykwalify.compat import yml
+ from testfixtures import compare
+ 
+ 
+@@ -579,7 +579,7 @@ def test_core_files(self):
+         for passing_test_file in pass_tests:
+             f = self.f(os.path.join("success", passing_test_file))
+             with open(f, "r") as stream:
+-                yaml_data = yaml.safe_load_all(stream)
++                yaml_data = yml.load_all(stream)
+ 
+                 for document_index, document in enumerate(yaml_data):
+                     data = document["data"]
+@@ -600,7 +600,7 @@ def test_core_files(self):
+         for failing_test, exception_type in _fail_tests:
+             f = self.f(os.path.join("fail", failing_test))
+             with open(f, "r") as stream:
+-                yaml_data = yaml.safe_load_all(stream)
++                yaml_data = yml.load_all(stream)
+ 
+                 for document_index, document in enumerate(yaml_data):
+                     data = document["data"]
+diff --git a/tests/test_unicode.py b/tests/test_unicode.py
+index 36f5549..74e2908 100644
+--- a/tests/test_unicode.py
++++ b/tests/test_unicode.py
+@@ -12,7 +12,7 @@
+ from pykwalify.errors import SchemaError
+ 
+ # 3rd party imports
+-from pykwalify.compat import yaml
++from pykwalify.compat import yml
+ from testfixtures import compare
+ 
+ 
+@@ -47,7 +47,8 @@ def test_files_with_unicode_content_success(self, tmpdir):
+         }
+ 
+         source_f = tmpdir.join(u"2så.json")
+-        source_f.write(yaml.safe_dump(fail_data_2s_yaml, allow_unicode=True))
++        with source_f.open('w') as stream:
++            yml.dump(fail_data_2s_yaml, stream)
+ 
+         _pass_tests = [
+             # Test mapping with unicode key and value
+@@ -65,7 +66,7 @@ def test_files_with_unicode_content_success(self, tmpdir):
+             f = self.f(passing_test_files)
+ 
+             with open(f, "r") as stream:
+-                yaml_data = yaml.safe_load(stream)
++                yaml_data = yml.load(stream)
+                 data = yaml_data["data"]
+                 schema = yaml_data["schema"]
+ 
+@@ -102,7 +103,8 @@ def test_files_with_unicode_content_failing(self, tmpdir):
+         }
+ 
+         source_f = tmpdir.join(u"2få.json")
+-        source_f.write(yaml.safe_dump(fail_data_2f_yaml, allow_unicode=True))
++        with source_f.open('w') as stream:
++            yml.dump(fail_data_2f_yaml, stream)
+ 
+         _fail_tests = [
+             # Test mapping with unicode key and value but wrong type
+@@ -120,7 +122,7 @@ def test_files_with_unicode_content_failing(self, tmpdir):
+             f = self.f(failing_test)
+ 
+             with open(f, "r") as stream:
+-                yaml_data = yaml.safe_load(stream)
++                yaml_data = yml.load(stream)
+                 data = yaml_data["data"]
+                 schema = yaml_data["schema"]
+                 errors = yaml_data["errors"]

diff --git a/dev-python/pykwalify/pykwalify-1.8.0-r3.ebuild 
b/dev-python/pykwalify/pykwalify-1.8.0-r3.ebuild
index 3276aa080f7a..a1bc5e9ac190 100644
--- a/dev-python/pykwalify/pykwalify-1.8.0-r3.ebuild
+++ b/dev-python/pykwalify/pykwalify-1.8.0-r3.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -33,4 +33,6 @@ distutils_enable_tests pytest
 
 PATCHES=(
        "${FILESDIR}"/${PN}-1.4.0-S.patch
+       # fix tests for >=dev-python/ruamel-yaml-1.18, see #923136
+       "${FILESDIR}"/${PN}-1.8.0-ruamel-yaml-1.18.patch
 )

Reply via email to