Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-flexmock for openSUSE:Factory 
checked in at 2021-09-03 21:26:06
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-flexmock (Old)
 and      /work/SRC/openSUSE:Factory/.python-flexmock.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-flexmock"

Fri Sep  3 21:26:06 2021 rev:5 rq:915211 version:0.10.8

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-flexmock/python-flexmock.changes  
2019-04-02 09:21:52.216687124 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-flexmock.new.1899/python-flexmock.changes    
    2021-09-03 21:26:53.094224877 +0200
@@ -1,0 +2,21 @@
+Tue Aug 31 08:53:33 UTC 2021 - Steve Kowalik <steven.kowa...@suse.com>
+
+- Update to 0.10.8:
+  * Fix with_args not working built-in functions. 
+
+-------------------------------------------------------------------
+Wed Aug 25 09:55:08 UTC 2021 - John Paul Adrian Glaubitz 
<adrian.glaub...@suse.com>
+
+- Update to 0.10.7:
+  - Fix ``with_args`` not working built-in functions and methods.
+  - Fix previous pytest ``--durations`` fix not working.
+- from version 0.10.6
+  - Fix flexmock broken with Pytest 4 & 5.
+  - Fix new_instances method not working with Python 2.7.
+  - Fix multiple expectations for the same classmethod are not matched.
+- from version 0.10.5
+  - Improve error message on unmatched method signature expectation.
+  - Fix using ``should_call`` passes wrong ``runtime_self``.
+  - Fix pytest ``--durations`` flag when flexmock is installed.
+
+-------------------------------------------------------------------
@@ -38 +58,0 @@
-

Old:
----
  flexmock-0.10.4.tar.gz

New:
----
  flexmock-0.10.8.tar.gz

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

Other differences:
------------------
++++++ python-flexmock.spec ++++++
--- /var/tmp/diff_new_pack.Exg9Lf/_old  2021-09-03 21:26:53.574225825 +0200
+++ /var/tmp/diff_new_pack.Exg9Lf/_new  2021-09-03 21:26:53.574225825 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-flexmock
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,11 +18,10 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-flexmock
-Version:        0.10.4
+Version:        0.10.8
 Release:        0
 Summary:        Testing library for creating mocks, stubs and fakes
 License:        BSD-2-Clause
-Group:          Development/Languages/Python
 URL:            https://github.com/bkabrda/flexmock
 Source:         
https://files.pythonhosted.org/packages/source/f/flexmock/flexmock-%{version}.tar.gz
 BuildRequires:  %{python_module pytest}

++++++ flexmock-0.10.4.tar.gz -> flexmock-0.10.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flexmock-0.10.4/CHANGELOG 
new/flexmock-0.10.8/CHANGELOG
--- old/flexmock-0.10.4/CHANGELOG       2019-03-25 10:58:29.000000000 +0100
+++ new/flexmock-0.10.8/CHANGELOG       2021-08-28 02:15:25.000000000 +0200
@@ -1,3 +1,56 @@
+This project follows semantic versioning.
+
+Types of changes:
+
+- **Added**: New features.
+- **Changed**: Changes in existing functionality.
+- **Deprecated**: Soon-to-be removed features.
+- **Removed**: Removed features.
+- **Fixed**: Bug fixes.
+- **Infrastructure**: Changes in build or deployment infrastructure.
+- **Documentation**: Changes in documentation.
+
+Release 0.10.8
+--------------
+
+Fixed
+#####
+
+- Fix ``with_args`` not working built-in functions.
+
+Release 0.10.7
+--------------
+
+Fixed
+#####
+
+- Fix ``with_args`` not working built-in methods.
+- Fix previous pytest ``--durations`` fix not working.
+
+Release 0.10.6
+--------------
+
+Fixed
+#####
+
+- Fix flexmock broken with Pytest 4 & 5.
+- Fix new_instances method not working with Python 2.7.
+- Fix multiple expectations for the same classmethod are not matched.
+
+Release 0.10.5
+--------------
+
+Added
+#####
+
+- Improve error message on unmatched method signature expectation.
+
+Fixed
+#####
+
+- Fix using ``should_call`` passes wrong ``runtime_self``.
+- Fix pytest ``--durations`` flag when flexmock is installed.
+
 Release 0.10.4
 --------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flexmock-0.10.4/PKG-INFO new/flexmock-0.10.8/PKG-INFO
--- old/flexmock-0.10.4/PKG-INFO        2019-03-25 11:04:06.000000000 +0100
+++ new/flexmock-0.10.8/PKG-INFO        2021-08-28 02:20:22.439960200 +0200
@@ -1,44 +1,11 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
 Name: flexmock
-Version: 0.10.4
+Version: 0.10.8
 Summary: flexmock is a testing library for Python that makes it easy to create 
mocks,stubs and fakes.
 Home-page: http://flexmock.readthedocs.org
 Author: Slavek Kabrda, Herman Sheremetyev
 Author-email: sla...@redhat.com
 License: BSD License
-Description: flexmock
-        ========
-        
-        .. image:: https://travis-ci.org/bkabrda/flexmock.svg?branch=master
-            :target: https://travis-ci.org/bkabrda/flexmock
-        
-        .. image:: 
https://coveralls.io/repos/bkabrda/flexmock/badge.svg?branch=master&service=github
-            :target: https://coveralls.io/github/bkabrda/flexmock?branch=master
-        
-        flexmock is a testing library for Python that makes it easy to create 
mocks, stubs and fakes.
-        ::
-        
-            from flexmock import flexmock
-            flexmock(pirate).should_receive('drink').with_args('full 
bottle').and_return('empty bottle')
-        
-        Its API is inspired by a Ruby library of the same name. However, it is 
not a goal of Python flexmock to be a clone of the Ruby version. Instead, the 
focus is on providing full support for testing Python programs and making the 
creation of fake objects as unobtrusive as possible.
-        
-        As a result, Python flexmock removes a number of redundancies in the 
Ruby flexmock API, alters some defaults, and introduces a number of Python-only 
features.
-        
-        flexmock???s design focuses on simplicity and intuitivenes. This means 
that the API is as lean as possible, though a few convenient short-hand methods 
are provided to aid brevity and readability.
-        
-        flexmock declarations are structured to read more like English 
sentences than API calls, and it is possible to chain them together in any 
order to achieve high degree of expressiveness in a single line of code.
-        
-        In addition, flexmock integrates seamlessly with all major test 
runners to reduce even more mock-related boilerplate code.
-        
-        More details, including full API and user documentation, available 
here:
-        
-        https://flexmock.readthedocs.org
-        
-        To report bugs or file feature requests:
-        
-        https://github.com/bkabrda/flexmock/issues
-        
 Keywords: flexmock mock stub test unittest pytest nose
 Platform: UNKNOWN
 Classifier: License :: OSI Approved :: BSD License
@@ -49,3 +16,39 @@
 Classifier: Programming Language :: Python :: Implementation :: Jython
 Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Topic :: Software Development :: Testing
+License-File: LICENSE
+
+flexmock
+========
+
+.. image:: https://travis-ci.org/bkabrda/flexmock.svg?branch=master
+    :target: https://travis-ci.org/bkabrda/flexmock
+
+.. image:: 
https://coveralls.io/repos/bkabrda/flexmock/badge.svg?branch=master&service=github
+    :target: https://coveralls.io/github/bkabrda/flexmock?branch=master
+
+flexmock is a testing library for Python that makes it easy to create mocks, 
stubs and fakes.
+::
+
+    from flexmock import flexmock
+    flexmock(pirate).should_receive('drink').with_args('full 
bottle').and_return('empty bottle')
+
+Its API is inspired by a Ruby library of the same name. However, it is not a 
goal of Python flexmock to be a clone of the Ruby version. Instead, the focus 
is on providing full support for testing Python programs and making the 
creation of fake objects as unobtrusive as possible.
+
+As a result, Python flexmock removes a number of redundancies in the Ruby 
flexmock API, alters some defaults, and introduces a number of Python-only 
features.
+
+flexmock???s design focuses on simplicity and intuitivenes. This means that 
the API is as lean as possible, though a few convenient short-hand methods are 
provided to aid brevity and readability.
+
+flexmock declarations are structured to read more like English sentences than 
API calls, and it is possible to chain them together in any order to achieve 
high degree of expressiveness in a single line of code.
+
+In addition, flexmock integrates seamlessly with all major test runners to 
reduce even more mock-related boilerplate code.
+
+More details, including full API and user documentation, available here:
+
+https://flexmock.readthedocs.org
+
+To report bugs or file feature requests:
+
+https://github.com/bkabrda/flexmock/issues
+
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flexmock-0.10.4/docs/conf.py 
new/flexmock-0.10.8/docs/conf.py
--- old/flexmock-0.10.4/docs/conf.py    2019-03-25 10:58:48.000000000 +0100
+++ new/flexmock-0.10.8/docs/conf.py    2021-08-28 02:17:37.000000000 +0200
@@ -51,7 +51,7 @@
 # built documents.
 #
 # The short X.Y version.
-version = '0.10.4'
+version = '0.10.8'
 # The full version, including alpha/beta/rc tags.
 release = version
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flexmock-0.10.4/flexmock.egg-info/PKG-INFO 
new/flexmock-0.10.8/flexmock.egg-info/PKG-INFO
--- old/flexmock-0.10.4/flexmock.egg-info/PKG-INFO      2019-03-25 
11:04:06.000000000 +0100
+++ new/flexmock-0.10.8/flexmock.egg-info/PKG-INFO      2021-08-28 
02:20:22.000000000 +0200
@@ -1,44 +1,11 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
 Name: flexmock
-Version: 0.10.4
+Version: 0.10.8
 Summary: flexmock is a testing library for Python that makes it easy to create 
mocks,stubs and fakes.
 Home-page: http://flexmock.readthedocs.org
 Author: Slavek Kabrda, Herman Sheremetyev
 Author-email: sla...@redhat.com
 License: BSD License
-Description: flexmock
-        ========
-        
-        .. image:: https://travis-ci.org/bkabrda/flexmock.svg?branch=master
-            :target: https://travis-ci.org/bkabrda/flexmock
-        
-        .. image:: 
https://coveralls.io/repos/bkabrda/flexmock/badge.svg?branch=master&service=github
-            :target: https://coveralls.io/github/bkabrda/flexmock?branch=master
-        
-        flexmock is a testing library for Python that makes it easy to create 
mocks, stubs and fakes.
-        ::
-        
-            from flexmock import flexmock
-            flexmock(pirate).should_receive('drink').with_args('full 
bottle').and_return('empty bottle')
-        
-        Its API is inspired by a Ruby library of the same name. However, it is 
not a goal of Python flexmock to be a clone of the Ruby version. Instead, the 
focus is on providing full support for testing Python programs and making the 
creation of fake objects as unobtrusive as possible.
-        
-        As a result, Python flexmock removes a number of redundancies in the 
Ruby flexmock API, alters some defaults, and introduces a number of Python-only 
features.
-        
-        flexmock???s design focuses on simplicity and intuitivenes. This means 
that the API is as lean as possible, though a few convenient short-hand methods 
are provided to aid brevity and readability.
-        
-        flexmock declarations are structured to read more like English 
sentences than API calls, and it is possible to chain them together in any 
order to achieve high degree of expressiveness in a single line of code.
-        
-        In addition, flexmock integrates seamlessly with all major test 
runners to reduce even more mock-related boilerplate code.
-        
-        More details, including full API and user documentation, available 
here:
-        
-        https://flexmock.readthedocs.org
-        
-        To report bugs or file feature requests:
-        
-        https://github.com/bkabrda/flexmock/issues
-        
 Keywords: flexmock mock stub test unittest pytest nose
 Platform: UNKNOWN
 Classifier: License :: OSI Approved :: BSD License
@@ -49,3 +16,39 @@
 Classifier: Programming Language :: Python :: Implementation :: Jython
 Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Topic :: Software Development :: Testing
+License-File: LICENSE
+
+flexmock
+========
+
+.. image:: https://travis-ci.org/bkabrda/flexmock.svg?branch=master
+    :target: https://travis-ci.org/bkabrda/flexmock
+
+.. image:: 
https://coveralls.io/repos/bkabrda/flexmock/badge.svg?branch=master&service=github
+    :target: https://coveralls.io/github/bkabrda/flexmock?branch=master
+
+flexmock is a testing library for Python that makes it easy to create mocks, 
stubs and fakes.
+::
+
+    from flexmock import flexmock
+    flexmock(pirate).should_receive('drink').with_args('full 
bottle').and_return('empty bottle')
+
+Its API is inspired by a Ruby library of the same name. However, it is not a 
goal of Python flexmock to be a clone of the Ruby version. Instead, the focus 
is on providing full support for testing Python programs and making the 
creation of fake objects as unobtrusive as possible.
+
+As a result, Python flexmock removes a number of redundancies in the Ruby 
flexmock API, alters some defaults, and introduces a number of Python-only 
features.
+
+flexmock???s design focuses on simplicity and intuitivenes. This means that 
the API is as lean as possible, though a few convenient short-hand methods are 
provided to aid brevity and readability.
+
+flexmock declarations are structured to read more like English sentences than 
API calls, and it is possible to chain them together in any order to achieve 
high degree of expressiveness in a single line of code.
+
+In addition, flexmock integrates seamlessly with all major test runners to 
reduce even more mock-related boilerplate code.
+
+More details, including full API and user documentation, available here:
+
+https://flexmock.readthedocs.org
+
+To report bugs or file feature requests:
+
+https://github.com/bkabrda/flexmock/issues
+
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flexmock-0.10.4/flexmock.py 
new/flexmock-0.10.8/flexmock.py
--- old/flexmock-0.10.4/flexmock.py     2019-03-25 10:59:04.000000000 +0100
+++ new/flexmock-0.10.8/flexmock.py     2021-08-28 02:17:21.000000000 +0200
@@ -25,7 +25,7 @@
 
 # from flexmock import * is evil, keep it from doing any damage
 __all__ = ['flexmock']
-__version__ = '0.10.4'
+__version__ = '0.10.8'
 
 
 import inspect
@@ -33,7 +33,6 @@
 import sys
 import types
 
-
 AT_LEAST = 'at least'
 AT_MOST = 'at most'
 EXACTLY = 'exactly'
@@ -247,21 +246,25 @@
         if isinstance(self._mock, Mock):
             return  # no sense in enforcing this for fake objects
         allowed = self.argspec
-        # we consider object a method for purposes or not counting 
"self"/"cls" as argument if:
-        #  - one of inspect.ismethod, inspect.isfunction, _isclass return True
-        #    (in Python 3 it's sometimes impossible to tell whether callable 
is method or not,
-        #     so we try both inspect.ismethod and inspect.isfunction; classes 
are callable too -
-        #     they have __init__)
-        #  - it's not a static method
-        #  - the mocked object is a module - module "methods" are in fact 
plain functions;
-        #    unless they're classes, which means they still have __init__
-        is_method = ((inspect.ismethod(self.original) or 
inspect.isfunction(self.original)
-                      or _isclass(self.original)) and
-                     self.method_type is not staticmethod and
-                     (not isinstance(self._mock, types.ModuleType) or
-                      _isclass(self.original)))
         args_len = len(allowed.args)
-        if is_method:
+
+        # self is the first expected argument
+        has_self = allowed.args and allowed.args[0] == "self"
+        # Builtin methods take `self` as the first argument but 
`inspect.ismethod` returns False
+        # so we need to check for them explicitly
+        is_builtin_method = isinstance(self.original, types.BuiltinMethodType) 
and has_self
+        # Methods take `self` if not a staticmethod
+        is_method = inspect.ismethod(self.original) and self.method_type is 
not staticmethod
+        # Class init takes `self`
+        is_class = inspect.isclass(self.original)
+        # When calling class methods or instance methods on a class method 
takes `cls`
+        is_class_method = (
+            inspect.isfunction(self.original)
+            and inspect.isclass(self._mock)
+            and self.method_type is not staticmethod
+        )
+        if is_builtin_method or is_method or is_class or is_class_method:
+            # Do not count `self` or `cls`.
             args_len -= 1
         minimum = args_len - (allowed.defaults and len(allowed.defaults) or 0)
         maximum = None
@@ -834,20 +837,29 @@
     def _update_method(self, expectation, name):
         method_instance = self._create_mock_method(name)
         obj = self._object
-        if _hasattr(obj, name) and not hasattr(expectation, 'original'):
-            expectation._update_original(name, obj)
-            method_type = type(_getattr(expectation, 'original'))
-            try:
-                # TODO(herman): this is awful, fix this properly.
-                # When a class/static method is mocked out on an *instance*
-                # we need to fetch the type from the class
-                method_type = type(_getattr(obj.__class__, name))
-            except:
-                pass
-            if method_type in SPECIAL_METHODS:
-                expectation.original_function = getattr(obj, name)
-            expectation.method_type = method_type
-        override = _setattr(obj, name, types.MethodType(method_instance, obj))
+        if _hasattr(obj, name):
+            if hasattr(expectation, 'original'):
+                expectation.method_type = type(_getattr(expectation, 
'original'))
+            else:
+                expectation._update_original(name, obj)
+                method_type = type(_getattr(expectation, 'original'))
+                try:
+                    # TODO(herman): this is awful, fix this properly.
+                    # When a class/static method is mocked out on an *instance*
+                    # we need to fetch the type from the class
+                    method_type = type(_getattr(obj.__class__, name))
+                except:
+                    pass
+                if method_type in SPECIAL_METHODS:
+                    expectation.original_function = getattr(obj, name)
+                expectation.method_type = method_type
+        if (
+            not _isclass(obj)
+            or expectation.method_type in SPECIAL_METHODS
+            or name == '__new__'
+        ):
+            method_instance = types.MethodType(method_instance, obj)
+        override = _setattr(obj, name, method_instance)
         expectation._local_override = override
         if (override and not _isclass(obj) and not isinstance(obj, Mock) and
                 hasattr(obj.__class__, name)):
@@ -946,45 +958,56 @@
                        (expected_values[0].value, return_values)))
             return return_values
 
+        def _handle_matched_expectation(expectation, runtime_self, *kargs, 
**kwargs):
+            if not expectation.runnable():
+                raise StateError('%s expected to be called when %s is True' %
+                                 (name, expectation._get_runnable()))
+            expectation.times_called += 1
+            expectation.verify(final=False)
+            _pass_thru = _getattr(expectation, '_pass_thru')
+            _replace_with = _getattr(expectation, '_replace_with')
+            if _pass_thru:
+                return pass_thru(expectation, runtime_self, *kargs, **kwargs)
+            elif _replace_with:
+                return _replace_with(*kargs, **kwargs)
+            return_values = _getattr(expectation, 'return_values')
+            if return_values:
+                return_value = return_values[0]
+                del return_values[0]
+                return_values.append(return_value)
+            else:
+                return_value = ReturnValue()
+            if return_value.raises:
+                if _isclass(return_value.raises):
+                    raise return_value.raises(
+                        *return_value.value['kargs'], 
**return_value.value['kwargs'])
+                else:
+                    raise return_value.raises
+            else:
+                return return_value.value
+
         def mock_method(runtime_self, *kargs, **kwargs):
             arguments = {'kargs': kargs, 'kwargs': kwargs}
             expectation = FlexmockContainer.get_flexmock_expectation(
                 self, name, arguments)
             if expectation:
-                if not expectation.runnable():
-                    raise StateError('%s expected to be called when %s is 
True' %
-                                     (name, expectation._get_runnable()))
-                expectation.times_called += 1
-                expectation.verify(final=False)
-                _pass_thru = _getattr(expectation, '_pass_thru')
-                _replace_with = _getattr(expectation, '_replace_with')
-                if _pass_thru:
-                    return pass_thru(expectation, runtime_self, *kargs, 
**kwargs)
-                elif _replace_with:
-                    return _replace_with(*kargs, **kwargs)
-                return_values = _getattr(expectation, 'return_values')
-                if return_values:
-                    return_value = return_values[0]
-                    del return_values[0]
-                    return_values.append(return_value)
-                else:
-                    return_value = ReturnValue()
-                if return_value.raises:
-                    if _isclass(return_value.raises):
-                        raise return_value.raises(
-                            *return_value.value['kargs'], 
**return_value.value['kwargs'])
-                    else:
-                        raise return_value.raises
-                else:
-                    return return_value.value
-            else:
-                # make sure to clean up expectations to ensure none of them
-                # interfere with the runner's error reporing mechanism
-                # e.g. open()
-                for _, expectations in 
FlexmockContainer.flexmock_objects.items():
-                    for expectation in expectations:
-                        _getattr(expectation, 'reset')()
-                raise MethodSignatureError(_format_args(name, arguments))
+                return _handle_matched_expectation(expectation, runtime_self, 
*kargs, **kwargs)
+            # inform the user which expectation(s) for the method were _not_ 
matched
+            expectations = [
+                e for e in 
reversed(FlexmockContainer.flexmock_objects.get(self, []))
+                if e.name == name
+            ]
+            error_msg = _format_args(name, arguments)
+            if expectations:
+                for e in expectations:
+                    error_msg += '\nDid not match expectation %s' % 
_format_args(name, e.args)
+            # make sure to clean up expectations to ensure none of them
+            # interfere with the runner's error reporting mechanism
+            # e.g. open()
+            for _, expectations in FlexmockContainer.flexmock_objects.items():
+                for expectation in expectations:
+                    _getattr(expectation, 'reset')()
+            raise MethodSignatureError(error_msg)
 
         return mock_method
 
@@ -1233,6 +1256,9 @@
                 return ret
             if hasattr(runner.CallInfo, "from_call"):
                 teardown = runner.CallInfo.from_call(flexmock_teardown, 
when=when)
+                if hasattr(teardown, "duration"):
+                    # CallInfo.duration only available in Pytest 6+
+                    teardown.duration = ret.duration
             else:
                 teardown = runner.CallInfo(flexmock_teardown, when=when)
                 teardown.result = None
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flexmock-0.10.4/setup.py new/flexmock-0.10.8/setup.py
--- old/flexmock-0.10.4/setup.py        2019-03-25 10:59:17.000000000 +0100
+++ new/flexmock-0.10.8/setup.py        2021-08-28 02:17:30.000000000 +0200
@@ -6,7 +6,7 @@
     from distutils.core import setup
 
 setup(name='flexmock',
-      version='0.10.4',
+      version='0.10.8',
       author='Slavek Kabrda, Herman Sheremetyev',
       author_email='sla...@redhat.com',
       url='http://flexmock.readthedocs.org',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flexmock-0.10.4/tests/flexmock_test.py 
new/flexmock-0.10.8/tests/flexmock_test.py
--- old/flexmock-0.10.4/tests/flexmock_test.py  2019-03-14 15:13:41.000000000 
+0100
+++ new/flexmock-0.10.8/tests/flexmock_test.py  2021-08-28 02:15:25.000000000 
+0200
@@ -1,4 +1,4 @@
-# -*- coding: utf8 -*-
+# -*- coding: utf-8 -*-
 from flexmock import EXACTLY
 from flexmock import AT_LEAST
 from flexmock import AT_MOST
@@ -18,6 +18,8 @@
 from flexmock import _format_args
 from flexmock import _isproperty
 import flexmock
+import random
+import os
 import re
 import sys
 import unittest
@@ -32,6 +34,18 @@
 
 module_level_attribute = 'test'
 
+class SomeClass:
+    @classmethod
+    def class_method(cls, a):
+        pass
+
+    @staticmethod
+    def static_method(a):
+        pass
+
+    def instance_method(self, a):
+        pass
+
 
 class OldStyleClass:
     pass
@@ -296,6 +310,24 @@
         assertEqual('got an int', mock.method_foo(23))
         assertRaises(MethodSignatureError, mock.method_foo, 2.0)
 
+    def test_with_args_should_work_with_builtin_c_methods(self):
+        if sys.version_info > (3, 0):
+            flexmock(sys.stdout).should_call("write")  # set fall-through
+            
flexmock(sys.stdout).should_receive("write").with_args("flexmock_builtin_test").once()
+            sys.stdout.write("flexmock_builtin_test")
+
+    def test_with_args_should_work_with_builtin_c_functions(self):
+        mocked = flexmock(sys)
+        mocked.should_receive("exit").with_args(1).once()
+        mocked.exit(1)
+        self._tear_down()
+        flexmock(os).should_receive("remove").with_args("path").once()
+        os.remove("path")
+
+    def test_with_args_should_work_with_builtin_python_methods(self):
+        flexmock(random).should_receive("randint").with_args(1, 10).once()
+        random.randint(1, 10)
+
     def 
test_flexmock_should_match_expectations_against_user_defined_classes(self):
         mock = flexmock(name='temp')
 
@@ -514,15 +546,58 @@
 
     def test_should_call_on_class_mock(self):
         class User:
-            def foo(self): return 'class'
+            def __init__(self):
+                self.value = 'value'
+
+            def foo(self):
+                return 'class'
+
+            def bar(self):
+                return self.value
+
         user1 = User()
         user2 = User()
+
+        # Access class-level method
         flexmock(User).should_call('foo').once()
         assertRaises(MethodCallError, self._tear_down)
         flexmock(User).should_call('foo').twice()
         assertEqual('class', user1.foo())
         assertEqual('class', user2.foo())
 
+        # Access instance attributes
+        flexmock(User).should_call('bar').once()
+        assertRaises(MethodCallError, self._tear_down)
+        flexmock(User).should_call('bar').twice()
+        assertEqual('value', user1.bar())
+        assertEqual('value', user2.bar())
+
+        # Try resetting the expectation
+        flexmock(User).should_call('bar').once()
+        assertEqual('value', user1.bar())
+
+    def test_with_args_on_class_mock(self):
+        # Instance method
+        
flexmock(SomeClass).should_receive("instance_method").with_args("red").once()
+        
flexmock(SomeClass).should_receive("instance_method").with_args("blue").once()
+        instance = SomeClass()
+        instance.instance_method("red")
+        instance.instance_method("blue")
+        self._tear_down()
+
+        # Class method
+        
flexmock(SomeClass).should_receive("class_method").with_args("red").once()
+        
flexmock(SomeClass).should_receive("class_method").with_args("blue").once()
+        SomeClass.class_method("red")
+        SomeClass.class_method("blue")
+        self._tear_down()
+
+        # Static method
+        
flexmock(SomeClass).should_receive("static_method").with_args("red").once()
+        
flexmock(SomeClass).should_receive("static_method").with_args("blue").once()
+        SomeClass.static_method("red")
+        SomeClass.static_method("blue")
+
     def 
test_flexmock_should_not_blow_up_on_should_call_for_class_methods(self):
         class User:
             @classmethod
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flexmock-0.10.4/tests/run_tests.sh 
new/flexmock-0.10.8/tests/run_tests.sh
--- old/flexmock-0.10.4/tests/run_tests.sh      2019-01-10 13:54:09.000000000 
+0100
+++ new/flexmock-0.10.8/tests/run_tests.sh      2021-08-28 02:15:18.000000000 
+0200
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 PYTHON_IMPLEMENTATIONS=${PYTHON_IMPLEMENTATIONS:-"python pypy jython"}
-python_VERSIONS=${PYTHON_VERSIONS:-"2.7 3.3 3.4 3.5"}
+python_VERSIONS=${PYTHON_VERSIONS:-"2.7 3.3 3.4 3.5 3.6 3.7 3.8 3.9"}
 pypy_VERSIONS=${PYPY_VERSIONS:-"nover 3"}
 jython_VERSIONS=${JYTHON_VERSIONS:-"nover"}
 

Reply via email to