Bug 2027383

Summary: libdnf fails to build with Python 3.11: AttributeError: 'PackageTest' object has no attribute 'assertEquals'
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: libdnfAssignee: amatej
Status: CLOSED DEFERRED QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 36CC: amatej, daniel.mach, jmracek, jrohel, mblaha, mhroncok, pkratoch, rpm-software-management, thrnciar
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-02-10 14:17:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2016048    

Description Tomáš Hrnčiar 2021-11-29 14:09:14 UTC
libdnf fails to build with Python 3.11.0a2.

4: ======================================================================
4: ERROR: test_hashability (tests.test_package.PackageTest)
4: Test that hawkey.Package objects are hashable.
4: ----------------------------------------------------------------------
4: Traceback (most recent call last):
4:   File "/builddir/build/BUILD/libdnf-0.65.0/python/hawkey/tests/tests/test_package.py", line 79, in test_hashability
4:     self.assertEquals(pkg2, pkg3)
4:     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4: AttributeError: 'PackageTest' object has no attribute 'assertEquals'
4: 
4: ======================================================================
4: ERROR: test_repr (tests.test_package.PackageTest)
4: ----------------------------------------------------------------------
4: Traceback (most recent call last):
4:   File "/builddir/build/BUILD/libdnf-0.65.0/python/hawkey/tests/tests/test_package.py", line 58, in test_repr
4:     self.assertRegexpMatches(repr(self.pkg), regexp)
4:     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4: AttributeError: 'PackageTest' object has no attribute 'assertRegexpMatches'
4: 
4: ----------------------------------------------------------------------
4: Ran 137 tests in 0.038s
4: 
4: FAILED (errors=2)

Removed many old deprecated unittest features:
    TestCase method aliases failUnlessEqual, failIfEqual, failUnless, failIf, failUnlessRaises, failUnlessAlmostEqual, failIfAlmostEqual (deprecated in Python 3.1), assertEquals, assertNotEquals, assert_, assertAlmostEquals, assertNotAlmostEquals, assertRegexpMatches, assertRaisesRegexp (deprecated in Python 3.2), and assertNotRegexpMatches (deprecated in Python 3.5).
    Undocumented and broken TestCase method assertDictContainsSubset (deprecated in Python 3.2).
    Undocumented <unittest.TestLoader.loadTestsFromModule> TestLoader.loadTestsFromModule() parameter use_load_tests (deprecated and ignored since Python 3.2).
    An alias of the TextTestResult class: _TextTestResult (deprecated in Python 3.2).

(Contributed by Serhiy Storchaka in bpo-45162.)

https://bugs.python.org/issue45162
https://docs.python.org/3.11/whatsnew/3.11.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/02992729-libdnf/

For all our attempts to build libdnf with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/libdnf/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.11:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 amatej 2021-12-02 09:32:38 UTC
I made a PR to fix the build: https://github.com/rpm-software-management/libdnf/pull/1389

I have tried it with my patch in a local mock and the build succeeded.

Comment 2 amatej 2021-12-06 09:25:13 UTC
I have also made a PR to fix dnf build: https://github.com/rpm-software-management/dnf/pull/1799

Comment 3 Ben Cotton 2022-02-08 21:22:40 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 36 development cycle.
Changing version to 36.

Comment 4 Tomáš Hrnčiar 2022-02-10 14:17:51 UTC
Removal of unittest aliases was reverted in Python 3.11 and will be part of Python 3.12, so the above failure is not present anymore, thus I am closing this bugzilla. However, this will be needed next year though so I encourage you to communicate with the upstream about it.

Comment 5 Tomáš Hrnčiar 2022-02-10 14:18:24 UTC
Removal of unittest aliases was reverted in Python 3.11 and will be part of Python 3.12, so the above failure is not present anymore, thus I am closing this bugzilla. However, this will be needed next year though so I encourage you to communicate with the upstream about it.