#8 [DO NOT MERGE] Update to 4.0.3 for Python 3.11 support
Merged 2 years ago by churchyard. Opened 2 years ago by churchyard.
rpms/ churchyard/python-mock 4  into  rawhide

file modified
+1
@@ -4,3 +4,4 @@ 

  /mock-1.3.0.tar.gz

  /mock-2.0.0.tar.gz

  /mock-3.0.5.tar.gz

+ /mock-4.0.3.tar.gz

file added
+73
@@ -0,0 +1,73 @@ 

+ From f3e3d82aab0ede7e25273806dc0505574d85eae2 Mon Sep 17 00:00:00 2001

+ From: Chris Withers <chris@simplistix.co.uk>

+ Date: Thu, 15 Apr 2021 08:27:25 +0100

+ Subject: [PATCH] fix tests that should test mock but were testing

+  unittest.mock

+ 

+ ---

+  mock/tests/testmock.py | 15 ++++++++-------

+  1 file changed, 8 insertions(+), 7 deletions(-)

+ 

+ diff --git a/mock/tests/testmock.py b/mock/tests/testmock.py

+ index 5702b6d..1a70909 100644

+ --- a/mock/tests/testmock.py

+ +++ b/mock/tests/testmock.py

+ @@ -13,6 +13,7 @@

+      create_autospec, mock

+  )

+  from mock.mock import _Call, _CallList

+ +import mock.mock as mock_module

+  

+  

+  class Iter(object):

+ @@ -47,7 +48,7 @@ def test_all(self):

+          # if __all__ is badly defined then import * will raise an error

+          # We have to exec it because you can't import * inside a method

+          # in Python 3

+ -        exec("from unittest.mock import *")

+ +        exec("from mock.mock import *")

+  

+  

+      def test_constructor(self):

+ @@ -2137,16 +2138,16 @@ def test_isinstance_under_settrace(self):

+          # test_patch_dict_test_prefix and test_patch_test_prefix not restoring

+          # causes the objects patched to go out of sync

+  

+ -        old_patch = unittest.mock.patch

+ +        old_patch = mock_module.patch

+  

+          # Directly using __setattr__ on unittest.mock causes current imported

+          # reference to be updated. Use a lambda so that during cleanup the

+          # re-imported new reference is updated.

+ -        self.addCleanup(lambda patch: setattr(unittest.mock, 'patch', patch),

+ +        self.addCleanup(lambda patch: setattr(mock_module, 'patch', patch),

+                          old_patch)

+  

+          with patch.dict('sys.modules'):

+ -            del sys.modules['unittest.mock']

+ +            del sys.modules['mock']

+  

+              # This trace will stop coverage being measured ;-)

+              def trace(frame, event, arg):  # pragma: no cover

+ @@ -2155,7 +2156,7 @@ def trace(frame, event, arg):  # pragma: no cover

+              self.addCleanup(sys.settrace, sys.gettrace())

+              sys.settrace(trace)

+  

+ -            from unittest.mock import (

+ +            from mock.mock import (

+                  Mock, MagicMock, NonCallableMock, NonCallableMagicMock

+              )

+  

+ @@ -2170,10 +2171,10 @@ def trace(frame, event, arg):  # pragma: no cover

+      def test_bool_not_called_when_passing_spec_arg(self):

+          class Something:

+              def __init__(self):

+ -                self.obj_with_bool_func = unittest.mock.MagicMock()

+ +                self.obj_with_bool_func = mock_module.MagicMock()

+  

+          obj = Something()

+ -        with unittest.mock.patch.object(obj, 'obj_with_bool_func', autospec=True): pass

+ +        with mock_module.patch.object(obj, 'obj_with_bool_func', autospec=True): pass

+  

+          self.assertEqual(obj.obj_with_bool_func.__bool__.call_count, 0)

+  

file modified
+10 -2
@@ -1,14 +1,18 @@ 

  %bcond_without tests

  

  Name:           python-mock

- Version:        3.0.5

- Release:        17%{?dist}

+ Version:        4.0.3

+ Release:        1%{?dist}

  Summary:        Deprecated, use unittest.mock from the standard library instead

  

  License:        BSD

  URL:            https://github.com/testing-cabal/mock

  Source0:        %{url}/archive/%{version}/mock-%{version}.tar.gz

  

+ # Fix tests that should test mock but were testing unittest.mock

+ # Merged upstream

+ Patch1:         %{url}/commit/f3e3d82aab.patch

+ 

  BuildArch:      noarch

  

  BuildRequires:  python%{python3_pkgversion}-devel
@@ -69,6 +73,10 @@ 

  

  

  %changelog

+ * Thu Jan 06 2022 Miro Hrončok <mhroncok@redhat.com> - 4.0.3-1

+ - Update to 4.0.3 for Python 3.11 support

+ - Fixes: rhbz#2019006

+ 

  * Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.5-17

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

  

file modified
+1 -1
@@ -1,1 +1,1 @@ 

- SHA512 (mock-3.0.5.tar.gz) = 9ab4f0c794f5701ba1367d982cf79a5662d4233753d12ed9c88ae20282db1f44be73f84c4d9f6d03ff64926b8c1b6d0c9a79b2a4724a3eb36c247ffd4ab03e2d

+ SHA512 (mock-4.0.3.tar.gz) = adfdab253eb3bc1b6cb767c58ffa3a8a5c5f88da0f04ea6680e0d87da59177972d2d99bfe0a770ac2ed4f809ca6a090a9d0f789eea8f4365ef2c54f8e8792e89

no initial comment

It builds with Python 3.11: https://copr.fedorainfracloud.org/coprs/g/python/python3.11/builds/?dirname=python3.11:pr:8


python-aws-sam-translator pins mock<4 -- @music can we get that unpinned or better yet migrate to unittest.mock? https://fedoraproject.org/wiki/Changes/DeprecatePythonMock#How_to_migrate_to_unittest.mock

From a SPEC sanity perspective this looks good.

python-aws-sam-translator pins mock<4 -- @music can we get that unpinned or better yet migrate to unittest.mock? https://fedoraproject.org/wiki/Changes/DeprecatePythonMock#How_to_migrate_to_unittest.mock

Absolutely. I didn’t notice it was generating a dependency on mock during initial packaging and review. Patching in https://github.com/aws/serverless-application-model/pull/2184 and fixing up the slight mismatch between the current release and development branches with sed will remove the mock dependency.

python-aws-sam-translator is fixed in Rawhide, with F35/F34 updates to follow.

I've verified that restview fails with mock 4 as well as with unittest.mock from the standard library.

But this fixes it: https://github.com/mgedmin/restview/commit/a1ded30a87c65f3ce59a18497a7fc5099317c2be

I've also opened https://github.com/mgedmin/restview/pull/62 for good measure.

Solution: https://src.fedoraproject.org/rpms/restview/pull-request/1

Pull-Request has been merged by churchyard

2 years ago

Well, I've obviously forgotten to rename this PR before merging, but it was ready.

Building python-mock-4.0.3-1.fc36 for rawhide
Created task: 81137710
Task info: https://koji.fedoraproject.org/koji/taskinfo?taskID=81137710