!18 [sync] PR-16: fix test with python 3.11

From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
This commit is contained in:
openeuler-ci-bot 2025-02-08 03:52:49 +00:00 committed by Gitee
commit 26e6c41e3c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 137 additions and 12 deletions

View File

@ -0,0 +1,96 @@
From d9a083bafaa2df338a3176ee9f1433718b3a1090 Mon Sep 17 00:00:00 2001
From: Jiri Hnidek <jhnidek@redhat.com>
Date: Wed, 11 May 2022 14:29:27 +0200
Subject: [PATCH 06/13] Fix compatibility issues with Python 3.11
* Fixes: https://github.com/candlepin/python-iniparse/issues/23
* BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2019017
* Replaced few deprecated methods with new methods
---
tests/test_compat.py | 20 ++++++++++----------
tests/test_fuzz.py | 2 +-
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tests/test_compat.py b/tests/test_compat.py
index ad36683..c8e6aca 100644
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -96,16 +96,16 @@ class TestCaseBase(unittest.TestCase):
eq(cf.get('Spaces', 'key with spaces'), 'value')
eq(cf.get('Spaces', 'another with spaces'), 'splat!')
- self.failIf('__name__' in cf.options("Foo Bar"),
+ self.assertFalse('__name__' in cf.options("Foo Bar"),
'__name__ "option" should not be exposed by the API!')
# Make sure the right things happen for remove_option();
# added to include check for SourceForge bug #123324:
- self.failUnless(cf.remove_option('Foo Bar', 'foo'),
+ self.assertTrue(cf.remove_option('Foo Bar', 'foo'),
"remove_option() failed to report existance of option")
- self.failIf(cf.has_option('Foo Bar', 'foo'),
+ self.assertFalse(cf.has_option('Foo Bar', 'foo'),
"remove_option() failed to remove option")
- self.failIf(cf.remove_option('Foo Bar', 'foo'),
+ self.assertFalse(cf.remove_option('Foo Bar', 'foo'),
"remove_option() failed to report non-existance of option"
" that was removed")
@@ -127,10 +127,10 @@ class TestCaseBase(unittest.TestCase):
eq(cf.options("a"), ["b"])
eq(cf.get("a", "b"), "value",
"could not locate option, expecting case-insensitive option names")
- self.failUnless(cf.has_option("a", "b"))
+ self.assertTrue(cf.has_option("a", "b"))
cf.set("A", "A-B", "A-B value")
for opt in ("a-b", "A-b", "a-B", "A-B"):
- self.failUnless(
+ self.assertTrue(
cf.has_option("A", opt),
"has_option() returned false for option which should exist")
eq(cf.options("A"), ["a-b"])
@@ -147,7 +147,7 @@ class TestCaseBase(unittest.TestCase):
# SF bug #561822:
cf = self.fromstring("[section]\nnekey=nevalue\n",
defaults={"key":"value"})
- self.failUnless(cf.has_option("section", "Key"))
+ self.assertTrue(cf.has_option("section", "Key"))
def test_default_case_sensitivity(self):
cf = self.newconfig({"foo": "Bar"})
@@ -182,7 +182,7 @@ class TestCaseBase(unittest.TestCase):
cf = self.newconfig()
self.assertEqual(cf.sections(), [],
"new ConfigParser should have no defined sections")
- self.failIf(cf.has_section("Foo"),
+ self.assertFalse(cf.has_section("Foo"),
"new ConfigParser should have no acknowledged sections")
self.assertRaises(ConfigParser.NoSectionError,
cf.options, "Foo")
@@ -221,8 +221,8 @@ class TestCaseBase(unittest.TestCase):
"E5=FALSE AND MORE"
)
for x in range(1, 5):
- self.failUnless(cf.getboolean('BOOLTEST', 't%d' % x))
- self.failIf(cf.getboolean('BOOLTEST', 'f%d' % x))
+ self.assertTrue(cf.getboolean('BOOLTEST', 't%d' % x))
+ self.assertFalse(cf.getboolean('BOOLTEST', 'f%d' % x))
self.assertRaises(ValueError,
cf.getboolean, 'BOOLTEST', 'e%d' % x)
diff --git a/tests/test_fuzz.py b/tests/test_fuzz.py
index df568bb..874ef2e 100644
--- a/tests/test_fuzz.py
+++ b/tests/test_fuzz.py
@@ -102,7 +102,7 @@ class TestFuzz(unittest.TestCase):
cc = compat.RawConfigParser()
cc.readfp(StringIO(s))
cc_py = configparser.RawConfigParser()
- cc_py.readfp(StringIO(s))
+ cc_py.read_file(StringIO(s))
# compare the two configparsers
self.assertEqualConfig(cc_py, cc)
# check that tidy does not change semantics
--
2.41.0

View File

@ -0,0 +1,29 @@
From 033c0aa3e1a51cb70a97762252059e70cc2f671c Mon Sep 17 00:00:00 2001
From: Daniel Garcia Moreno <daniel.garcia@suse.com>
Date: Wed, 20 Dec 2023 12:40:14 +0100
Subject: [PATCH] Fix tests with python 3.11.7
---
Backported to 0.5 (s/six/io/ below)
tests/test_compat.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/test_compat.py b/tests/test_compat.py
index 8d7c785..86d0524 100644
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -1,3 +1,4 @@
+import os
from iniparse import compat as ConfigParser
from six import StringIO
try:
@@ -263,6 +264,8 @@ class mystr(str):
def test_read_returns_file_list(self):
file1 = test_support.findfile("cfgparser.1")
+ if not os.path.exists(file1):
+ file1 = test_support.findfile("configdata/cfgparser.1")
# check when we pass a mix of readable and non-readable files:
cf = self.newconfig()
parsed_files = cf.read([file1, "nonexistant-file"])

View File

@ -1,15 +1,14 @@
#spec for tarball
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Name: python-iniparse
Version: 0.5
Release: 3
Release: 4
Summary: Python Module for Accessing and Modifying Configuration Data in INI files
License: MIT AND Python-2.0
URL: https://github.com/candlepin/python-iniparse
Source0: https://files.pythonhosted.org/packages/source/i/iniparse/iniparse-%{version}.tar.gz
Patch0: backport-fix-bug-in-classifiers.patch
Patch1: backport-Fix-compatibility-issues-with-Python-3.11.patch
Patch2: backport-Fix-tests-with-python-3.12.1.patch
BuildArch: noarch
@ -35,29 +34,30 @@ This package is the python3 version of python-iniparse.
%prep
%autosetup -n iniparse-%{version} -p1
%build
%py3_build
%install
%py3_install
rm -fr %{buildroot}%{_datadir}/doc
%check
export PYTHONPATH=%{buildroot}%{python3_sitelib}
%{__python3} runtests.py
%files -n python3-iniparse
%defattr(-,root,root,-)
%license LICENSE LICENSE-PSF
%{python3_sitelib}/iniparse
%{python3_sitelib}/iniparse-%{version}-py*.egg-info
%files help
%doc Changelog html/
%exclude %{_docdir}/iniparse-%{version}/
%changelog
* Thu Jan 23 2025 Funda Wang <fundawang@yeah.net> - 0.5-4
- fix test with python 3.11
* Wed Aug 14 2024 wangjiang <wangjiang37@h-partners.com> - 0.5-3
- Type:enhancement
- ID:NA

View File

@ -1,4 +1,4 @@
version_control: pypi
src_repo: iniparse
tag_prefix:
seperator: .
version_control: pypi
src_repo: iniparse
tag_prefix:
separator: .