Package: testresources
Followup-For: Bug #1056533
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu noble ubuntu-patch
Control: tags -1 patch

Dear Maintainer,

The testresources autopkgtest test-suite currently fails with Python
3.12 because it still uses unittest.TestCase.failIf.

failIf was a deprecated alias for assertFalse and was dropped from
Python 3.12.

Applying a patch from upstream allows the test-suite to pass with Python
3.12.

In Ubuntu, the attached patch was applied to achieve the following:


  * Fix test-suite so it can run with Python 3.12. (LP: #2045302)


Thanks for considering the patch.


-- System Information:
Debian Release: trixie/sid
  APT prefers mantic-updates
  APT policy: (500, 'mantic-updates'), (500, 'mantic-security'), (500, 'mantic')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.1.0-16-generic (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru testresources-2.0.1/debian/patches/python3.12.patch 
testresources-2.0.1/debian/patches/python3.12.patch
--- testresources-2.0.1/debian/patches/python3.12.patch 1970-01-01 
01:00:00.000000000 +0100
+++ testresources-2.0.1/debian/patches/python3.12.patch 2023-11-30 
18:59:39.000000000 +0100
@@ -0,0 +1,35 @@
+Description: Refactor failIf to assertFalse for Python 3.12 Compatibility
+ This commit replaces deprecated failIf calls with assertFalse in the
+ test_resourced_test_case.py file. The failIf method was removed in
+ Python 3.12 [1-3].
+ .
+ [1] https://docs.python.org/3.12/whatsnew/3.12.html#removed
+ [2] https://github.com/python/cpython/issues/89325
+ [3] https://github.com/python/cpython/pull/28268
+Author: Petr Vaněk <arka...@atlas.cz>
+Origin: upstream, https://github.com/testing-cabal/testresources/pull/15
+Bug: https://launchpad.net/bugs/2045302
+Bug-Ubuntu: https://launchpad.net/bugs/2045302
+Bug-Debian: https://bugs.debian.org/1056533
+Applied-Upstream: 
https://github.com/testing-cabal/testresources/commit/7bb62a13fa1d28717c10f3152b5e8ea479c8e9d2
+Last-Update: 2023-11-30
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/testresources/tests/test_resourced_test_case.py
++++ b/testresources/tests/test_resourced_test_case.py
+@@ -129,7 +129,7 @@
+         self.resourced_case.resources = [("foo", self.resource_manager)]
+         self.resourced_case.setUpResources()
+         self.resourced_case.tearDownResources()
+-        self.failIf(hasattr(self.resourced_case, "foo"))
++        self.assertFalse(hasattr(self.resourced_case, "foo"))
+ 
+     def testTearDownResourcesStopsUsingResource(self):
+         # tearDownResources records that there is one less use of each
+@@ -158,5 +158,5 @@
+         self.assertEqual(self.resourced_case.foo, self.resource)
+         self.assertEqual(self.resource_manager._uses, 1)
+         self.resourced_case.tearDown()
+-        self.failIf(hasattr(self.resourced_case, "foo"))
++        self.assertFalse(hasattr(self.resourced_case, "foo"))
+         self.assertEqual(self.resource_manager._uses, 0)
diff -Nru testresources-2.0.1/debian/patches/series 
testresources-2.0.1/debian/patches/series
--- testresources-2.0.1/debian/patches/series   2022-10-17 12:22:49.000000000 
+0200
+++ testresources-2.0.1/debian/patches/series   2023-11-30 18:59:07.000000000 
+0100
@@ -1,2 +1,3 @@
 remove-non-deterministic-ftbfs-testBasicSortTests.patch
 python3.10.patch
+python3.12.patch

Reply via email to