Run lxml tests during build, avoid deprecated unittest.makeSuite()

This commit is contained in:
Miro Hrončok
2023-10-24 13:32:26 +02:00
parent 4ec55d2b7e
commit 58bc1fca8e
2 changed files with 52 additions and 1 deletions

42
drop-makeSuite.patch Normal file
View File

@@ -0,0 +1,42 @@
From 4e6cea5f5bb44bf06dd30a723cf13334693c3150 Mon Sep 17 00:00:00 2001
From: Christian Heimes <christian@python.org>
Date: Fri, 22 Sep 2023 14:01:50 +0200
Subject: [PATCH] Improve tests (partial)
- `makeSuite` is deprecated
diff --git a/tests.py b/tests.py
index ab52aab..c60335e 100644
--- a/tests.py
+++ b/tests.py
@@ -542,17 +559,19 @@ def test_defused_gzip_response(self):
def test_main():
suite = unittest.TestSuite()
- suite.addTests(unittest.makeSuite(TestDefusedcElementTree))
- suite.addTests(unittest.makeSuite(TestDefusedElementTree))
- suite.addTests(unittest.makeSuite(TestDefusedMinidom))
- suite.addTests(unittest.makeSuite(TestDefusedMinidomWithParser))
- suite.addTests(unittest.makeSuite(TestDefusedPulldom))
- suite.addTests(unittest.makeSuite(TestDefusedSax))
- suite.addTests(unittest.makeSuite(TestXmlRpc))
- if lxml is not None:
- suite.addTests(unittest.makeSuite(TestDefusedLxml))
- if gzip is not None:
- suite.addTests(unittest.makeSuite(TestDefusedGzip))
+ cls = [
+ TestDefusedElementTree,
+ TestDefusedcElementTree,
+ TestDefusedMinidom,
+ TestDefusedMinidomWithParser,
+ TestDefusedPulldom,
+ TestDefusedSax,
+ TestDefusedLxml,
+ TestXmlRpc,
+ TestDefusedGzip,
+ ]
+ for c in cls:
+ suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(c))
return suite

View File

@@ -4,16 +4,22 @@
%global upstream_version %{base_version}%{?prerel}
Name: python-%{pypi_name}
Version: %{base_version}%{?prerel:~%{prerel}}
Release: 9%{?dist}
Release: 10%{?dist}
Summary: XML bomb protection for Python stdlib modules
License: Python
URL: https://github.com/tiran/defusedxml
Source0: %{pypi_source %{pypi_name} %{upstream_version}}
# Drop deprecated unittest.makeSuite()
# From https://github.com/tiran/defusedxml/commit/4e6cea5f5b
# (This no longer skips lxml tests when lxml is not installed.)
Patch: drop-makeSuite.patch
BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-lxml
%description
The defusedxml package contains several Python-only workarounds and fixes for
@@ -56,6 +62,9 @@ module. This is the python%{python3_pkgversion} build.
%changelog
* Tue Oct 24 2023 Miro Hrončok <mhroncok@redhat.com> - 0.7.1-10
- Run lxml tests during build, avoid deprecated unittest.makeSuite()
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.1-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild