python-mock fails to build with Python 3.11.0a1. =================================== FAILURES =================================== ________ TestMockingMagicMethods.test_setting_unsupported_magic_method _________ self = <mock.tests.testmagicmethods.TestMockingMagicMethods testMethod=test_setting_unsupported_magic_method> def test_setting_unsupported_magic_method(self): mock = MagicMock() def set_setattr(): mock.__setattr__ = lambda self, name: None > self.assertRaisesRegexp(AttributeError, "Attempting to set unsupported magic method '__setattr__'.", set_setattr ) E AttributeError: 'TestMockingMagicMethods' object has no attribute 'assertRaisesRegexp' mock/tests/testmagicmethods.py:428: AttributeError ___________________ MockTest.test_assert_called_once_message ___________________ self = <mock.tests.testmock.MockTest testMethod=test_assert_called_once_message> def test_assert_called_once_message(self): m = Mock() m(1, 2) m(3) > self.assertRaisesRegexp(AssertionError, re.escape("Calls: [call(1, 2), call(3)]"), m.assert_called_once) E AttributeError: 'MockTest' object has no attribute 'assertRaisesRegexp' mock/tests/testmock.py:1569: AttributeError _______________ MockTest.test_assert_called_once_with_call_list ________________ self = <mock.tests.testmock.MockTest testMethod=test_assert_called_once_with_call_list> def test_assert_called_once_with_call_list(self): m = Mock() m(1) m(2) > self.assertRaisesRegexp(AssertionError, re.escape("Calls: [call(1), call(2)]"), lambda: m.assert_called_once_with(2)) E AttributeError: 'MockTest' object has no attribute 'assertRaisesRegexp' mock/tests/testmock.py:438: AttributeError ________________ MockTest.test_assert_called_once_with_message _________________ self = <mock.tests.testmock.MockTest testMethod=test_assert_called_once_with_message> def test_assert_called_once_with_message(self): mock = Mock(name='geoffrey') > self.assertRaisesRegexp(AssertionError, r"Expected 'geoffrey' to be called once\.", mock.assert_called_once_with) E AttributeError: 'MockTest' object has no attribute 'assertRaisesRegexp' mock/tests/testmock.py:747: AttributeError ___________________ MockTest.test_assert_called_with_message ___________________ self = <mock.tests.testmock.MockTest testMethod=test_assert_called_with_message> def test_assert_called_with_message(self): mock = Mock() > self.assertRaisesRegexp(AssertionError, 'not called', mock.assert_called_with) E AttributeError: 'MockTest' object has no attribute 'assertRaisesRegexp' mock/tests/testmock.py:741: AttributeError ___________________ MockTest.test_assert_not_called_message ____________________ self = <mock.tests.testmock.MockTest testMethod=test_assert_not_called_message> def test_assert_not_called_message(self): m = Mock() m(1, 2) > self.assertRaisesRegexp(AssertionError, re.escape("Calls: [call(1, 2)]"), m.assert_not_called) E AttributeError: 'MockTest' object has no attribute 'assertRaisesRegexp' mock/tests/testmock.py:1540: AttributeError _________________ MockTest.test_autospec_side_effect_exception _________________ self = <mock.tests.testmock.MockTest testMethod=test_autospec_side_effect_exception> def test_autospec_side_effect_exception(self): # Test for issue 23661 def f(): pass mock = create_autospec(f) mock.side_effect = ValueError('Bazinga!') > self.assertRaisesRegexp(ValueError, 'Bazinga!', mock) E AttributeError: 'MockTest' object has no attribute 'assertRaisesRegexp' mock/tests/testmock.py:218: AttributeError ___________________________ MockTest.test_from_spec ____________________________ self = <mock.tests.testmock.MockTest testMethod=test_from_spec> def test_from_spec(self): class Something(object): x = 3 __something__ = None def y(self): pass def test_attributes(mock): # should work mock.x mock.y mock.__something__ self.assertRaisesRegexp( AttributeError, "Mock object has no attribute 'z'", getattr, mock, 'z' ) self.assertRaisesRegexp( AttributeError, "Mock object has no attribute '__foobar__'", getattr, mock, '__foobar__' ) > test_attributes(Mock(spec=Something)) mock/tests/testmock.py:567: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ mock = <Mock spec='Something' id='139979481356256'> def test_attributes(mock): # should work mock.x mock.y mock.__something__ > self.assertRaisesRegexp( AttributeError, "Mock object has no attribute 'z'", getattr, mock, 'z' ) E AttributeError: 'MockTest' object has no attribute 'assertRaisesRegexp' mock/tests/testmock.py:556: AttributeError ______________________ MockTest.test_mock_call_repr_loop _______________________ self = <mock.tests.testmock.MockTest testMethod=test_mock_call_repr_loop> def test_mock_call_repr_loop(self): m = Mock() m.foo = m repr(m.foo()) > self.assertRegexpMatches(repr(m.foo()), r"<Mock name='mock\(\)' id='\d+'>") E AttributeError: 'MockTest' object has no attribute 'assertRegexpMatches' mock/tests/testmock.py:1183: AttributeError ___________________ MockTest.test_only_allowed_methods_exist ___________________ self = <mock.tests.testmock.MockTest testMethod=test_only_allowed_methods_exist> def test_only_allowed_methods_exist(self): for spec in ['something'], ('something',): for arg in 'spec', 'spec_set': mock = Mock(**{arg: spec}) # this should be allowed mock.something > self.assertRaisesRegexp( AttributeError, "Mock object has no attribute 'something_else'", getattr, mock, 'something_else' ) E AttributeError: 'MockTest' object has no attribute 'assertRaisesRegexp' mock/tests/testmock.py:538: AttributeError =========================== short test summary info ============================ FAILED mock/tests/testmagicmethods.py::TestMockingMagicMethods::test_setting_unsupported_magic_method FAILED mock/tests/testmock.py::MockTest::test_assert_called_once_message - At... FAILED mock/tests/testmock.py::MockTest::test_assert_called_once_with_call_list FAILED mock/tests/testmock.py::MockTest::test_assert_called_once_with_message FAILED mock/tests/testmock.py::MockTest::test_assert_called_with_message - At... FAILED mock/tests/testmock.py::MockTest::test_assert_not_called_message - Att... FAILED mock/tests/testmock.py::MockTest::test_autospec_side_effect_exception FAILED mock/tests/testmock.py::MockTest::test_from_spec - AttributeError: 'Mo... FAILED mock/tests/testmock.py::MockTest::test_mock_call_repr_loop - Attribute... FAILED mock/tests/testmock.py::MockTest::test_only_allowed_methods_exist - At... ================== 10 failed, 387 passed, 9 skipped in 1.42s =================== In Python 3.11 many old deprecated unittest features are removed: 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://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/02910274-python-mock/ For all our attempts to build python-mock with Python 3.11, see: https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/python-mock/ 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 already included in Fedora 36. 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.
Looks fixed in the mock backport version 4.0.0, released Feb 2020. https://github.com/testing-cabal/mock/pull/476 https://github.com/testing-cabal/mock/commit/ce5b6961d0b38b9f26e6bffabf46fadfc55696ba https://github.com/testing-cabal/mock/releases/tag/4.0.0 Latest is 4.0.3, Dec 2020. https://pypi.org/project/mock/
I haven't been updating mock in Fedora as it is deprecated there: https://fedoraproject.org/wiki/Changes/DeprecatePythonMock Maybe we should do it to unblock this and if it breaks some packages, migrate them to the standard library.
https://src.fedoraproject.org/rpms/python-mock/pull-request/8
FEDORA-2022-2f5141c1dd has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-2f5141c1dd
FEDORA-2022-2f5141c1dd has been pushed to the Fedora 36 stable repository. If problem still persists, please make note of it in this bug report.