Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-mockito for openSUSE:Factory 
checked in at 2025-11-27 15:21:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-mockito (Old)
 and      /work/SRC/openSUSE:Factory/.python-mockito.new.14147 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-mockito"

Thu Nov 27 15:21:24 2025 rev:14 rq:1320290 version:1.5.5

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-mockito/python-mockito.changes    
2025-02-12 21:37:32.041086423 +0100
+++ /work/SRC/openSUSE:Factory/.python-mockito.new.14147/python-mockito.changes 
2025-11-27 15:23:04.040790884 +0100
@@ -1,0 +2,13 @@
+Wed Nov 26 13:59:37 UTC 2025 - John Paul Adrian Glaubitz 
<[email protected]>
+
+- Update to 1.5.5
+  * Improve behavior of a mock's ad hoc methods
+  * Improve the error message of the safety check in `get_function_host`
+  * Remove unrelated test in a test function
+  * Update CHANGES.txt
+  * Fix recipes markup
+  * Markup fix in "walk-through"
+  * Make `thenReturn()` an official shortcut
+  * Rename and order tests in `when_interface_test`
+
+-------------------------------------------------------------------

Old:
----
  1.5.4.tar.gz

New:
----
  1.5.5.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-mockito.spec ++++++
--- /var/tmp/diff_new_pack.DpV3bS/_old  2025-11-27 15:23:04.952829346 +0100
+++ /var/tmp/diff_new_pack.DpV3bS/_new  2025-11-27 15:23:04.952829346 +0100
@@ -18,7 +18,7 @@
 
 %{?sle15_python_module_pythons}
 Name:           python-mockito
-Version:        1.5.4
+Version:        1.5.5
 Release:        0
 Summary:        Spying framework
 License:        MIT

++++++ 1.5.4.tar.gz -> 1.5.5.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/.bumpversion.cfg 
new/mockito-python-1.5.5/.bumpversion.cfg
--- old/mockito-python-1.5.4/.bumpversion.cfg   2025-01-22 23:06:58.000000000 
+0100
+++ new/mockito-python-1.5.5/.bumpversion.cfg   2025-11-17 12:25:34.000000000 
+0100
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 1.5.4
+current_version = 1.5.5
 commit = True
 message = Bump version to {new_version}
 tag = True
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/CHANGES.txt 
new/mockito-python-1.5.5/CHANGES.txt
--- old/mockito-python-1.5.4/CHANGES.txt        2025-01-22 23:06:58.000000000 
+0100
+++ new/mockito-python-1.5.5/CHANGES.txt        2025-11-17 12:25:34.000000000 
+0100
@@ -1,8 +1,46 @@
 MOCKITO CHANGE LOG
 ==================
 
-Release 1.5.0
--------------------------------
+
+Release 1.5.5
+--------------------------------
+
+- Improved behavior of the ad-hoc methods of mocks.  (#92)
+- Make the shortcut `when(mock).foo().thenReturn()` officially work and just 
assume
+  the user forgot the `None` as return value.
+
+
+
+Release 1.5.4 (January 22, 2025)
+--------------------------------
+
+- Implement defined behavior for `deepcopy` for mocks.  (#91)
+
+
+
+Release 1.5.3 (November 9, 2024)
+--------------------------------
+
+- Maintenance release adding support for Python 3.13.
+
+
+
+Release 1.5.2 (November 6, 2024)
+--------------------------------
+
+- Fixed issue (#86) where you couldn't setup expectations for objects or mocks 
with an overridden `__eq__` method.
+
+
+
+Release 1.5.1 (September 4, 2024)
+---------------------------------
+
+- Fixed issue (#82) with methods which have arguments named `value` or 
`exception`.
+
+
+
+Release 1.5.0 (March 4, 2024)
+-----------------------------
 
 - @Oracking fixed `expect` to support a string as its first argument.  All
   other functions supported that already.  E.g.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/docs/recipes.rst 
new/mockito-python-1.5.5/docs/recipes.rst
--- old/mockito-python-1.5.4/docs/recipes.rst   2025-01-22 23:06:58.000000000 
+0100
+++ new/mockito-python-1.5.5/docs/recipes.rst   2025-11-17 12:25:34.000000000 
+0100
@@ -79,13 +79,22 @@
 Python's `deepcopy` is tied to `__deepcopy__`, in a nutshell `deepcopy(m)` 
will call `m.__deepcopy__()`.
 For a strict mock, `deepcopy(m)` will raise an error as long as the call is 
unexpected -- as usual.
 
-While you could completely fake it -- 
`when(m).__deepcopy__(...).thenReturn(42)` -- you could also enable
-the standard implementation by configuring the mock, e.g. 
`mock({"__deepcopy__": None}, strict=True)`.
+While you could completely fake it --
+
+::
+
+    when(m).__deepcopy__(...).thenReturn(42)
+
+-- you could also enable the standard implementation by configuring the mock, 
e.g.
+
+::
+
+    mock({"__deepcopy__": None}, strict=True)
 
 Dumb mocks are copied correctly by default.
 
 However, there is a possible catch: deep mutable objects must be set on the 
mock's instance, not the class.
-And the constructors configuration is set on the class, not the instance.  
Huh?  Let's show an example:
+And the constructors configuration is set on the class, not the instance.  
Huh?  Let's show an example::
 
     m = mock()
     m.foo = [1]  # <= this is set on the instance, not the class
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/docs/walk-through.rst 
new/mockito-python-1.5.5/docs/walk-through.rst
--- old/mockito-python-1.5.4/docs/walk-through.rst      2025-01-22 
23:06:58.000000000 +0100
+++ new/mockito-python-1.5.5/docs/walk-through.rst      2025-11-17 
12:25:34.000000000 +0100
@@ -13,7 +13,7 @@
 
 So in difference to traditional patching, in mockito you always specify 
concrete arguments (a call signature), and its outcome, usually a return value 
via `thenReturn` or a raised exception via `thenRaise`. That effectively turns 
function calls into constants for the time of the test.
 
-There are of course reasons when you don't want to overspecify specific tests. 
You _just_ want the desired stub answer. Here we go::
+There are of course reasons when you don't want to overspecify specific tests. 
You *just* want the desired stub answer. Here we go::
 
     when(os.path).exists(...).thenReturn(True)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/mockito/__init__.py 
new/mockito-python-1.5.5/mockito/__init__.py
--- old/mockito-python-1.5.4/mockito/__init__.py        2025-01-22 
23:06:58.000000000 +0100
+++ new/mockito-python-1.5.5/mockito/__init__.py        2025-11-17 
12:25:34.000000000 +0100
@@ -44,7 +44,7 @@
 from .matchers import any, contains, times
 from .verification import never
 
-__version__ = '1.5.4'
+__version__ = '1.5.5'
 
 __all__ = [
     'mock',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/mockito/invocation.py 
new/mockito-python-1.5.5/mockito/invocation.py
--- old/mockito-python-1.5.4/mockito/invocation.py      2025-01-22 
23:06:58.000000000 +0100
+++ new/mockito-python-1.5.5/mockito/invocation.py      2025-11-17 
12:25:34.000000000 +0100
@@ -431,13 +431,13 @@
             invocation.mock.eat_self(invocation.method_name)
 
     def thenReturn(self, *return_values):
-        for return_value in return_values:
+        for return_value in return_values or (None,):
             answer = return_(return_value)
             self.__then(answer)
         return self
 
     def thenRaise(self, *exceptions):
-        for exception in exceptions:
+        for exception in exceptions or (Exception,):
             answer = raise_(exception)
             self.__then(answer)
         return self
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/mockito/mocking.py 
new/mockito-python-1.5.5/mockito/mocking.py
--- old/mockito-python-1.5.4/mockito/mocking.py 2025-01-22 23:06:58.000000000 
+0100
+++ new/mockito-python-1.5.5/mockito/mocking.py 2025-11-17 12:25:34.000000000 
+0100
@@ -18,7 +18,6 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 
-import functools
 import inspect
 import operator
 from collections import deque
@@ -311,8 +310,20 @@
             ):
                 raise AttributeError(method_name)
 
-            return functools.partial(
-                remembered_invocation_builder, theMock, method_name)
+            def ad_hoc_function(*args, **kwargs):
+                return remembered_invocation_builder(
+                    theMock, method_name, *args, **kwargs)
+            ad_hoc_function.__name__ = method_name
+            ad_hoc_function.__self__ = obj  # type: ignore[attr-defined]
+            if spec:
+                try:
+                    original_method = getattr(spec, method_name)
+                    ad_hoc_function.__wrapped__ = original_method  # type: 
ignore[attr-defined]  # noqa: E501
+                    ad_hoc_function.__doc__ = original_method.__doc__
+                except AttributeError:
+                    pass
+
+            return ad_hoc_function
 
         def __repr__(self):
             name = 'Dummy'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/mockito/mockito.py 
new/mockito-python-1.5.5/mockito/mockito.py
--- old/mockito-python-1.5.4/mockito/mockito.py 2025-01-22 23:06:58.000000000 
+0100
+++ new/mockito-python-1.5.5/mockito/mockito.py 2025-11-17 12:25:34.000000000 
+0100
@@ -194,9 +194,12 @@
     expected call counts up front.
 
     If your function is pure side effect and does not return something, you
-    can omit the specific answer. The default then is `None`::
+    can omit the specific answer. The function will then return `None` as by
+    default for Python functions::
 
-        when(manager).do_work()
+        when(manager).do_work().thenReturn()
+        # However, using `expect` may read better.
+        expect(manager).do_work()
 
     `when` verifies the method name, the expected argument signature, and the
     actual, factual arguments your code under test uses against the original
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/mockito/utils.py 
new/mockito-python-1.5.5/mockito/utils.py
--- old/mockito-python-1.5.4/mockito/utils.py   2025-01-22 23:06:58.000000000 
+0100
+++ new/mockito-python-1.5.5/mockito/utils.py   2025-11-17 12:25:34.000000000 
+0100
@@ -65,8 +65,14 @@
 
         obj, name = find_invoking_frame_and_try_parse()
         # safety check!
-        assert getattr(obj, name) == fn
-
+        assert getattr(obj, name) == fn, (
+            "`getattr(obj, name) != fn` where\n"
+            "fn: %s\n"
+            "obj: %s\n"
+            "name: %s\n"
+            "getattr(obj, name): %s\n"
+            % (fn, obj, name, getattr(obj, name))
+        )
 
     return obj, name
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/pyproject.toml 
new/mockito-python-1.5.5/pyproject.toml
--- old/mockito-python-1.5.4/pyproject.toml     2025-01-22 23:06:58.000000000 
+0100
+++ new/mockito-python-1.5.5/pyproject.toml     2025-11-17 12:25:34.000000000 
+0100
@@ -1,6 +1,6 @@
 [project]
 name = "mockito"
-version = "1.5.4"
+version = "1.5.5"
 description = "Spying framework"
 authors = [
     { name = "herr kaste", email = "[email protected]" }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/tests/speccing_test.py 
new/mockito-python-1.5.5/tests/speccing_test.py
--- old/mockito-python-1.5.4/tests/speccing_test.py     2025-01-22 
23:06:58.000000000 +0100
+++ new/mockito-python-1.5.5/tests/speccing_test.py     2025-11-17 
12:25:34.000000000 +0100
@@ -33,6 +33,7 @@
         pass
 
     def run(self, arg):
+        """this is a docstring"""
         return arg
 
     def __call__(self, task):
@@ -47,7 +48,6 @@
         assert action.run(11) == 12
         verify(action).run(11)
 
-
     def testShouldScreamWhenStubbingUnknownMethod(self):
         action = mock(Action)
 
@@ -70,8 +70,6 @@
         action = mock({'foo': 'bar'}, spec=Action)
 
         assert action.foo == 'bar'
-        with pytest.raises(InvocationError):
-            when(action).remember()
 
     def testPreconfigureWithFunction(self):
         action = mock({
@@ -102,26 +100,47 @@
 
         assert isinstance(action, Action)
 
-    def testShouldPassIsInstanceChecks_2(self):
-        action = mock(spec=Action)
+    class TestVariousConstructorForms:
+        def testUsingKeywordArg(self):
+            action = mock(spec=Action)
 
-        assert isinstance(action, Action)
+            assert isinstance(action, Action)
 
-    def testShouldPassIsInstanceChecks_3(self):
-        action = mock({}, Action)
+        def testUsingPositionalArg(self):
+            action = mock(Action)
 
-        assert isinstance(action, Action)
+            assert isinstance(action, Action)
 
-    def testShouldPassIsInstanceChecks_4(self):
-        action = mock({}, spec=Action)
+        def testKeywordAfterConfigurationObject(self):
+            action = mock({}, spec=Action)
 
-        assert isinstance(action, Action)
+            assert isinstance(action, Action)
+
+        def testPositionalArgAfterConfigurationObject(self):
+            action = mock({}, Action)
 
-    def testHasANiceName(self):
+            assert isinstance(action, Action)
+
+    def testMockHasANiceName(self):
         action = mock(Action)
 
         assert repr(action) == "<DummyAction id=%s>" % id(action)
 
+    def testConfiguredMethodHasCorrectName(self):
+        action = mock(Action)
+        when(action).run(11).thenReturn(12)
+        assert action.run.__name__ == 'run'
+
+    def testConfiguredMethodIsBound(self):
+        action = mock(Action)
+        when(action).run(11).thenReturn(12)
+        assert action.run.__self__ == action
+
+    def testConfiguredMethodHasCorrectDocstring(self):
+        action = mock(Action)
+        when(action).run(11).thenReturn(12)
+        assert action.run.__doc__ == 'this is a docstring'
+
 
 class TestSpeccingLoose:
     def testReturnNoneForEveryMethod(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/tests/when2_test.py 
new/mockito-python-1.5.5/tests/when2_test.py
--- old/mockito-python-1.5.4/tests/when2_test.py        2025-01-22 
23:06:58.000000000 +0100
+++ new/mockito-python-1.5.5/tests/when2_test.py        2025-11-17 
12:25:34.000000000 +0100
@@ -1,7 +1,7 @@
 
 import pytest
 
-from mockito import when2, patch, spy2, verify
+from mockito import mock, when2, patch, spy2, verify
 from mockito.utils import newmethod
 
 
@@ -147,3 +147,19 @@
             with pytest.raises(TypeError) as exc:
                 ptch(os.path.exists, lambda: 'boo')
             assert str(exc.value) == "could not destructure first argument"
+
+
+class TestFixIssue90:
+    def testAddAttributeToDumbMock(self):
+        m = mock()
+        when2(m.foo).thenReturn('bar')
+        assert m.foo() == 'bar'
+
+    @pytest.mark.xfail(reason=(
+        "strict mocks throw when accessing unconfigured attributes by design"
+    ))
+    def testAddAttributeToStrictMock(self):
+        m = mock(strict=True)
+        when2(m.foo).thenReturn('bar')
+        assert m.foo() == 'bar'
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mockito-python-1.5.4/tests/when_interface_test.py 
new/mockito-python-1.5.5/tests/when_interface_test.py
--- old/mockito-python-1.5.4/tests/when_interface_test.py       2025-01-22 
23:06:58.000000000 +0100
+++ new/mockito-python-1.5.5/tests/when_interface_test.py       2025-11-17 
12:25:34.000000000 +0100
@@ -19,7 +19,7 @@
 
 
 @pytest.mark.usefixtures('unstub')
-class TestUserExposedInterfaces:
+class TestEnsureEmptyInterfacesAreReturned:
 
     def testWhen(self):
         whening = when(Dog)
@@ -35,9 +35,24 @@
         assert verifying.__dict__ == {}
 
 
-    def testEnsureUnhashableObjectCanBeMocked(self):
-        obj = Unhashable()
-        when(obj).update().thenReturn(None)
+def testEnsureUnhashableObjectCanBeMocked():
+    obj = Unhashable()
+    when(obj).update().thenReturn(None)
+
+
+class TestAnswerShortcuts:
+    def testAssumeReturnNoneIfOmitted(self):
+        dog = Dog()
+        when(dog).bark().thenReturn().thenReturn(42)
+        assert dog.bark() is None
+        assert dog.bark() == 42
+
+    def testAssumeRaiseExceptionIfOmitted(self):
+        dog = Dog()
+        when(dog).bark().thenRaise().thenReturn(42)
+        with pytest.raises(Exception):
+            dog.bark()
+        assert dog.bark() == 42
 
 
 @pytest.mark.usefixtures('unstub')
@@ -92,13 +107,22 @@
         verify(Dog).waggle()
         verify(Dog).weggle()
 
-    # Where to put this test?
-    def testEnsureAddedAttributesGetRemovedOnUnstub(self):
+
+class TestEnsureAddedAttributesGetRemovedOnUnstub:
+    def testWhenPatchingTheClass(self):
         with when(Dog, strict=False).wggle():
             pass
 
         with pytest.raises(AttributeError):
-            getattr(Dog, 'wggle')
+            Dog.wggle
+
+    def testWhenPatchingAnInstance(self):
+        dog = Dog()
+        with when(dog, strict=False).wggle():
+            pass
+
+        with pytest.raises(AttributeError):
+            dog.wggle
 
 
 @pytest.mark.usefixtures('unstub')

Reply via email to