[Python-modules-commits] [pytest-mock] 01/04: Import pytest-mock_1.1.orig.tar.gz

Vincent Bernat bernat at moszumanska.debian.org
Sat Jul 2 14:44:18 UTC 2016


This is an automated email from the git hooks/post-receive script.

bernat pushed a commit to branch master
in repository pytest-mock.

commit 4c5a29cf296e517d1c6aef496076acb43139ed1f
Author: Vincent Bernat <bernat at debian.org>
Date:   Sat Jul 2 16:40:05 2016 +0200

    Import pytest-mock_1.1.orig.tar.gz
---
 LICENSE                                   | 186 +++----------------
 PKG-INFO                                  | 192 ++++++++++++--------
 README.rst                                | 182 +++++++++++--------
 PKG-INFO => pytest_mock.egg-info/PKG-INFO | 192 ++++++++++++--------
 pytest_mock.egg-info/SOURCES.txt          |  13 ++
 pytest_mock.egg-info/dependency_links.txt |   1 +
 pytest_mock.egg-info/entry_points.txt     |   3 +
 pytest_mock.egg-info/requires.txt         |   4 +
 pytest_mock.egg-info/top_level.txt        |   1 +
 pytest_mock.py                            | 150 ++++++++++++++-
 setup.py                                  |  18 +-
 test_pytest_mock.py                       | 293 ++++++++++++++++++++++++++++--
 12 files changed, 821 insertions(+), 414 deletions(-)

diff --git a/LICENSE b/LICENSE
index 1dd90f2..72a8093 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,165 +1,21 @@
-GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
-  This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
-  0. Additional Definitions.
-
-  As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
-  "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
-  An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
-  A "Combined Work" is a work produced by combining or linking an
-Application with the Library.  The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
-  The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
-  The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
-  1. Exception to Section 3 of the GNU GPL.
-
-  You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
-  2. Conveying Modified Versions.
-
-  If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
-   a) under this License, provided that you make a good faith effort to
-   ensure that, in the event an Application does not supply the
-   function or data, the facility still operates, and performs
-   whatever part of its purpose remains meaningful, or
-
-   b) under the GNU GPL, with none of the additional permissions of
-   this License applicable to that copy.
-
-  3. Object Code Incorporating Material from Library Header Files.
-
-  The object code form of an Application may incorporate material from
-a header file that is part of the Library.  You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
-   a) Give prominent notice with each copy of the object code that the
-   Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the object code with a copy of the GNU GPL and this license
-   document.
-
-  4. Combined Works.
-
-  You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
-   a) Give prominent notice with each copy of the Combined Work that
-   the Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the Combined Work with a copy of the GNU GPL and this license
-   document.
-
-   c) For a Combined Work that displays copyright notices during
-   execution, include the copyright notice for the Library among
-   these notices, as well as a reference directing the user to the
-   copies of the GNU GPL and this license document.
-
-   d) Do one of the following:
-
-       0) Convey the Minimal Corresponding Source under the terms of this
-       License, and the Corresponding Application Code in a form
-       suitable for, and under terms that permit, the user to
-       recombine or relink the Application with a modified version of
-       the Linked Version to produce a modified Combined Work, in the
-       manner specified by section 6 of the GNU GPL for conveying
-       Corresponding Source.
-
-       1) Use a suitable shared library mechanism for linking with the
-       Library.  A suitable mechanism is one that (a) uses at run time
-       a copy of the Library already present on the user's computer
-       system, and (b) will operate properly with a modified version
-       of the Library that is interface-compatible with the Linked
-       Version.
-
-   e) Provide Installation Information, but only if you would otherwise
-   be required to provide such information under section 6 of the
-   GNU GPL, and only to the extent that such information is
-   necessary to install and execute a modified version of the
-   Combined Work produced by recombining or relinking the
-   Application with a modified version of the Linked Version. (If
-   you use option 4d0, the Installation Information must accompany
-   the Minimal Corresponding Source and Corresponding Application
-   Code. If you use option 4d1, you must provide the Installation
-   Information in the manner specified by section 6 of the GNU GPL
-   for conveying Corresponding Source.)
-
-  5. Combined Libraries.
-
-  You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
-   a) Accompany the combined library with a copy of the same work based
-   on the Library, uncombined with any other library facilities,
-   conveyed under the terms of this License.
-
-   b) Give prominent notice with the combined library that part of it
-   is a work based on the Library, and explaining where to find the
-   accompanying uncombined form of the same work.
-
-  6. Revised Versions of the GNU Lesser General Public License.
-
-  The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
-  Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
-  If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
\ No newline at end of file
+MIT License
+
+Copyright (c) [2016] [Bruno Oliveira]
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/PKG-INFO b/PKG-INFO
index 47b3137..1ee9ff6 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,55 +1,56 @@
 Metadata-Version: 1.1
 Name: pytest-mock
-Version: 0.8.1
+Version: 1.1
 Summary: Thin-wrapper around the mock package for easier use with py.test
 Home-page: https://github.com/pytest-dev/pytest-mock/
 Author: Bruno Oliveira
 Author-email: nicoddemus at gmail.com
-License: LGPL
+License: MIT
 Description: ===========
         pytest-mock
         ===========
         
         This plugin installs a ``mocker`` fixture which is a thin-wrapper around the patching API
-        provided by the excellent `mock <http://pypi.python.org/pypi/mock>`_ package,
+        provided by the `mock package <http://pypi.python.org/pypi/mock>`_,
         but with the benefit of not having to worry about undoing patches at the end
         of a test:
         
         .. code-block:: python
         
-         
+        
             def test_unix_fs(mocker):
                 mocker.patch('os.remove')
                 UnixFS.rm('file')
                 os.remove.assert_called_once_with('file')
-                
+        
         
         .. Using PNG badges because PyPI doesn't support SVG
         
-        |python| |version| |downloads| |ci| |coverage|
+        |python| |version| |downloads| |ci| |appveyor| |coverage|
         
         .. |version| image:: http://img.shields.io/pypi/v/pytest-mock.png
           :target: https://pypi.python.org/pypi/pytest-mock
-          
+        
         .. |downloads| image:: http://img.shields.io/pypi/dm/pytest-mock.png
           :target: https://pypi.python.org/pypi/pytest-mock
         
         .. |ci| image:: http://img.shields.io/travis/pytest-dev/pytest-mock.png
           :target: https://travis-ci.org/pytest-dev/pytest-mock
         
+        .. |appveyor| image:: https://ci.appveyor.com/api/projects/status/pid1t7iuwhkm9eh6/branch/master?svg=true
+          :target: https://ci.appveyor.com/project/pytestbot/pytest-mock
+        
         .. |coverage| image:: http://img.shields.io/coveralls/pytest-dev/pytest-mock.png
           :target: https://coveralls.io/r/pytest-dev/pytest-mock
         
-        .. |python| image:: https://pypip.in/py_versions/pytest-mock/badge.png
+        .. |python| image:: https://img.shields.io/pypi/pyversions/pytest-mock.svg
           :target: https://pypi.python.org/pypi/pytest-mock/
-          :alt: Supported Python versions
-        
         
         Usage
         =====
         
         The ``mocker`` fixture has the same API as
-        `mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators>`_, 
+        `mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators>`_,
         supporting the same arguments:
         
         .. code-block:: python
@@ -59,54 +60,31 @@ Description: ===========
                 mocker.patch('os.remove')
                 mocker.patch.object(os, 'listdir', autospec=True)
                 mocked_isfile = mocker.patch('os.path.isfile')
-            
+        
         The supported methods are:
-            
+        
         * ``mocker.patch``: see http://www.voidspace.org.uk/python/mock/patch.html#patch.
         * ``mocker.patch.object``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-object.
         * ``mocker.patch.multiple``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-multiple.
         * ``mocker.patch.dict``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-dict.
-        * ``mocker.stopall()``: stops all active patches at this point.
+        * ``mocker.stopall()``: stops all active patches up to this point.
+        * ``mocker.resetall()``: calls ``reset_mock()`` in all mocked objects up to this point. 
         
-        Note that, although mocker's API is intentionally the same as ``mock.patch``'s, its uses as context managers and function decorators are **not** supported. The purpose of this plugin is to make the use of context managers and function decorators for mocking unnecessary. Indeed, trying to use the functionality in ``mocker`` in this manner can lead to non-intuitive errors:
+        Some objects from the ``mock`` module are accessible directly from ``mocker`` for convenience:
         
-        .. code-block:: python
+        * `Mock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock>`_
+        * `MagicMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.MagicMock>`_
+        * `PropertyMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.PropertyMock>`_
+        * `ANY <https://docs.python.org/3/library/unittest.mock.html#any>`_
+        * `call <https://docs.python.org/3/library/unittest.mock.html#call>`_ *(Version 1.1)*
         
-            def test_context_manager(mocker):
-                a = A()
-                with mocker.patch.object(a, 'doIt', return_value=True, autospec=True):
-                    assert a.doIt() == True
-        
-        .. code-block:: console
-        
-            ================================== FAILURES ===================================
-            ____________________________ test_context_manager _____________________________
-            in test_context_manager
-                with mocker.patch.object(a, 'doIt', return_value=True, autospec=True):
-            E   AttributeError: __exit__
-        
-        
-        You can also access ``Mock`` and ``MagicMock`` directly using from ``mocker``
-        fixture:
-        
-        .. code-block:: python
-        
-            def test_feature(mocker):
-                ret = [mocker.Mock(return_value=True), mocker.Mock(return_value=True)]
-                mocker.patch('mylib.func', side_effect=ret)
-        
-        *New in version 0.5*
         
         Spy
         ---
         
-        *New in version 0.6*
-        
         The spy acts exactly like the original method in all cases, except it allows use of `mock`
-        features with it, like retrieving call count.
+        features with it, like retrieving call count. It also works for class and static methods.
         
-        From version 0.7 onward it also works for class and static methods. Originally it was only safe to
-        use with instance methods.
         
         .. code-block:: python
         
@@ -123,9 +101,9 @@ Description: ===========
         Stub
         ----
         
-        *New in version 0.6*
         
         The stub is a mock object that accepts any arguments and is useful to test callbacks, for instance.
+        May be passed a name to be used by the constructed stub object in its repr (useful for debugging).
         
         .. code-block:: python
         
@@ -133,28 +111,60 @@ Description: ===========
                 def foo(on_something):
                     on_something('foo', 'bar')
         
-                stub = mocker.stub()
+                stub = mocker.stub(name='on_something_stub')
         
                 foo(stub)
                 stub.assert_called_once_with('foo', 'bar')
         
-        Note
-        ----
         
-        Prior to version ``0.4.0``, the ``mocker`` fixture was named ``mock``.
-        This was changed because naming the fixture ``mock`` conflicts with the
-        actual ``mock`` module, which made using it awkward when access to both the
-        module and the plugin were required within a test.
+        Improved reporting of mock call assertion errors
+        ------------------------------------------------
+        
+        
+        This plugin monkeypatches the mock library to improve pytest output for failures
+        of mock call assertions like ``Mock.assert_called_with()`` by hiding internal traceback
+        entries from the ``mock`` module.
+        
+        It also adds introspection information on differing call arguments when
+        calling the helper methods. This features catches `AssertionError` raised in
+        the method, and uses py.test's own `advanced assertions`_ to return a better
+        diff::
+        
+        
+                    m = mocker.patch.object(DS, 'create_char')
+                    DS().create_char('Raistlin', class_='mag', gift=12)
+            >       m.assert_called_once_with('Raistlin', class_='mage', gift=12)
+            E       assert {'class_': 'mag', 'gift': 12} == {'class_': 'mage', 'gift': 12}
+            E         Omitting 1 identical items, use -v to show
+            E         Differing items:
+            E         {'class_': 'mag'} != {'class_': 'mage'}
+            E         Use -v to get the full diff
+        
+        
+        This is useful when asserting mock calls with many/nested arguments and trying
+        to quickly see the difference.
+        
+        This feature is probably safe, but if you encounter any problems it can be disabled in
+        your ``pytest.ini`` file:
+        
+        .. code-block:: ini
+        
+            [pytest]
+            mock_traceback_monkeypatch = false
+        
+        Note that this feature is automatically disabled with the ``--tb=native`` option. The underlying
+        mechanism used to suppress traceback entries from ``mock`` module does not work with that option
+        anyway plus it generates confusing messages on Python 3.5 due to exception chaining
+        
+        .. _advanced assertions: https://pytest.org/latest/assert.html
         
-        The old fixture ``mock`` still works, but its use is discouraged and will be
-        removed in version ``1.0``.
         
         Requirements
         ============
         
-        * Python 2.6+, Python 3.2+
+        * Python 2.6+, Python 3.3+
         * pytest
-        * mock (for Python < 3.3)
+        * mock (for Python 2)
         
         
         Install
@@ -163,19 +173,21 @@ Description: ===========
         Install using `pip <http://pip-installer.org/>`_:
         
         .. code-block:: console
-            
+        
             $ pip install pytest-mock
         
         Changelog
         =========
         
-        Please consult `releases <https://github.com/pytest-dev/pytest-mock/releases>`_.
-                
+        Please consult the `changelog page`_.
+        
+        .. _changelog page: https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst
+        
         Why bother with a plugin?
         =========================
         
-        There are a number of different ``patch`` usages in the standard ``mock`` API, 
-        but IMHO they don't scale very well when you have more than one or two 
+        There are a number of different ``patch`` usages in the standard ``mock`` API,
+        but IMHO they don't scale very well when you have more than one or two
         patches to apply.
         
         It may lead to an excessive nesting of ``with`` statements, breaking the flow
@@ -184,21 +196,21 @@ Description: ===========
         .. code-block:: python
         
             import mock
-            
+        
             def test_unix_fs():
                 with mock.patch('os.remove'):
                     UnixFS.rm('file')
                     os.remove.assert_called_once_with('file')
-                    
+        
                     with mock.patch('os.listdir'):
                         assert UnixFS.ls('dir') == expected
                         # ...
-                        
+        
                 with mock.patch('shutil.copy'):
                     UnixFS.cp('src', 'dst')
                     # ...
-                    
-                
+        
+        
         One can use ``patch`` as a decorator to improve the flow of the test:
         
         .. code-block:: python
@@ -209,31 +221,61 @@ Description: ===========
             def test_unix_fs(mocked_copy, mocked_listdir, mocked_remove):
                 UnixFS.rm('file')
                 os.remove.assert_called_once_with('file')
-                
+        
                 assert UnixFS.ls('dir') == expected
                 # ...
-                        
+        
                 UnixFS.cp('src', 'dst')
                 # ...
-                
-        But this poses a few disadvantages:        
         
-        - test functions must receive the mock objects as parameter, even if you don't plan to 
-          access them directly; also, order depends on the order of the decorated ``patch`` 
+        But this poses a few disadvantages:
+        
+        - test functions must receive the mock objects as parameter, even if you don't plan to
+          access them directly; also, order depends on the order of the decorated ``patch``
           functions;
         - receiving the mocks as parameters doesn't mix nicely with pytest's approach of
           naming fixtures as parameters, or ``pytest.mark.parametrize``;
         - you can't easily undo the mocking during the test execution;
         
+        
+        **Note**
+        
+        Although mocker's API is intentionally the same as ``mock.patch``'s, its uses as context managers and function decorators are **not** supported. The purpose of this plugin is to make the use of context managers and function decorators for mocking unnecessary. Indeed, trying to use the functionality in ``mocker`` in this manner can lead to non-intuitive errors:
+        
+        .. code-block:: python
+        
+            def test_context_manager(mocker):
+                a = A()
+                with mocker.patch.object(a, 'doIt', return_value=True, autospec=True):
+                    assert a.doIt() == True
+        
+        .. code-block:: console
+        
+            ================================== FAILURES ===================================
+            ____________________________ test_context_manager _____________________________
+            in test_context_manager
+                with mocker.patch.object(a, 'doIt', return_value=True, autospec=True):
+            E   AttributeError: __exit__
+        
+        
+        License
+        =======
+        
+        Distributed under the terms of the `MIT`_ license.
+        
+        .. _MIT: https://github.com/pytest-dev/pytest-mock/blob/master/LICENSE
+        
 Keywords: pytest mock
 Platform: any
-Classifier: Development Status :: 3 - Alpha
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Framework :: Pytest
 Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
+Classifier: License :: OSI Approved :: MIT License
 Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Topic :: Software Development :: Testing
diff --git a/README.rst b/README.rst
index 28c02d7..d0d3033 100644
--- a/README.rst
+++ b/README.rst
@@ -3,45 +3,46 @@ pytest-mock
 ===========
 
 This plugin installs a ``mocker`` fixture which is a thin-wrapper around the patching API
-provided by the excellent `mock <http://pypi.python.org/pypi/mock>`_ package,
+provided by the `mock package <http://pypi.python.org/pypi/mock>`_,
 but with the benefit of not having to worry about undoing patches at the end
 of a test:
 
 .. code-block:: python
 
- 
+
     def test_unix_fs(mocker):
         mocker.patch('os.remove')
         UnixFS.rm('file')
         os.remove.assert_called_once_with('file')
-        
+
 
 .. Using PNG badges because PyPI doesn't support SVG
 
-|python| |version| |downloads| |ci| |coverage|
+|python| |version| |downloads| |ci| |appveyor| |coverage|
 
 .. |version| image:: http://img.shields.io/pypi/v/pytest-mock.png
   :target: https://pypi.python.org/pypi/pytest-mock
-  
+
 .. |downloads| image:: http://img.shields.io/pypi/dm/pytest-mock.png
   :target: https://pypi.python.org/pypi/pytest-mock
 
 .. |ci| image:: http://img.shields.io/travis/pytest-dev/pytest-mock.png
   :target: https://travis-ci.org/pytest-dev/pytest-mock
 
+.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/pid1t7iuwhkm9eh6/branch/master?svg=true
+  :target: https://ci.appveyor.com/project/pytestbot/pytest-mock
+
 .. |coverage| image:: http://img.shields.io/coveralls/pytest-dev/pytest-mock.png
   :target: https://coveralls.io/r/pytest-dev/pytest-mock
 
-.. |python| image:: https://pypip.in/py_versions/pytest-mock/badge.png
+.. |python| image:: https://img.shields.io/pypi/pyversions/pytest-mock.svg
   :target: https://pypi.python.org/pypi/pytest-mock/
-  :alt: Supported Python versions
-
 
 Usage
 =====
 
 The ``mocker`` fixture has the same API as
-`mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators>`_, 
+`mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators>`_,
 supporting the same arguments:
 
 .. code-block:: python
@@ -51,54 +52,31 @@ supporting the same arguments:
         mocker.patch('os.remove')
         mocker.patch.object(os, 'listdir', autospec=True)
         mocked_isfile = mocker.patch('os.path.isfile')
-    
+
 The supported methods are:
-    
+
 * ``mocker.patch``: see http://www.voidspace.org.uk/python/mock/patch.html#patch.
 * ``mocker.patch.object``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-object.
 * ``mocker.patch.multiple``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-multiple.
 * ``mocker.patch.dict``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-dict.
-* ``mocker.stopall()``: stops all active patches at this point.
+* ``mocker.stopall()``: stops all active patches up to this point.
+* ``mocker.resetall()``: calls ``reset_mock()`` in all mocked objects up to this point. 
 
-Note that, although mocker's API is intentionally the same as ``mock.patch``'s, its uses as context managers and function decorators are **not** supported. The purpose of this plugin is to make the use of context managers and function decorators for mocking unnecessary. Indeed, trying to use the functionality in ``mocker`` in this manner can lead to non-intuitive errors:
+Some objects from the ``mock`` module are accessible directly from ``mocker`` for convenience:
 
-.. code-block:: python
+* `Mock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock>`_
+* `MagicMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.MagicMock>`_
+* `PropertyMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.PropertyMock>`_
+* `ANY <https://docs.python.org/3/library/unittest.mock.html#any>`_
+* `call <https://docs.python.org/3/library/unittest.mock.html#call>`_ *(Version 1.1)*
 
-    def test_context_manager(mocker):
-        a = A()
-        with mocker.patch.object(a, 'doIt', return_value=True, autospec=True):
-            assert a.doIt() == True
-
-.. code-block:: console
-
-    ================================== FAILURES ===================================
-    ____________________________ test_context_manager _____________________________
-    in test_context_manager
-        with mocker.patch.object(a, 'doIt', return_value=True, autospec=True):
-    E   AttributeError: __exit__
-
-
-You can also access ``Mock`` and ``MagicMock`` directly using from ``mocker``
-fixture:
-
-.. code-block:: python
-
-    def test_feature(mocker):
-        ret = [mocker.Mock(return_value=True), mocker.Mock(return_value=True)]
-        mocker.patch('mylib.func', side_effect=ret)
-
-*New in version 0.5*
 
 Spy
 ---
 
-*New in version 0.6*
-
 The spy acts exactly like the original method in all cases, except it allows use of `mock`
-features with it, like retrieving call count.
+features with it, like retrieving call count. It also works for class and static methods.
 
-From version 0.7 onward it also works for class and static methods. Originally it was only safe to
-use with instance methods.
 
 .. code-block:: python
 
@@ -115,9 +93,9 @@ use with instance methods.
 Stub
 ----
 
-*New in version 0.6*
 
 The stub is a mock object that accepts any arguments and is useful to test callbacks, for instance.
+May be passed a name to be used by the constructed stub object in its repr (useful for debugging).
 
 .. code-block:: python
 
@@ -125,28 +103,60 @@ The stub is a mock object that accepts any arguments and is useful to test callb
         def foo(on_something):
             on_something('foo', 'bar')
 
-        stub = mocker.stub()
+        stub = mocker.stub(name='on_something_stub')
 
         foo(stub)
         stub.assert_called_once_with('foo', 'bar')
 
-Note
-----
 
-Prior to version ``0.4.0``, the ``mocker`` fixture was named ``mock``.
-This was changed because naming the fixture ``mock`` conflicts with the
-actual ``mock`` module, which made using it awkward when access to both the
-module and the plugin were required within a test.
+Improved reporting of mock call assertion errors
+------------------------------------------------
+
+
+This plugin monkeypatches the mock library to improve pytest output for failures
+of mock call assertions like ``Mock.assert_called_with()`` by hiding internal traceback
+entries from the ``mock`` module.
+
+It also adds introspection information on differing call arguments when
+calling the helper methods. This features catches `AssertionError` raised in
+the method, and uses py.test's own `advanced assertions`_ to return a better
+diff::
+
+
+            m = mocker.patch.object(DS, 'create_char')
+            DS().create_char('Raistlin', class_='mag', gift=12)
+    >       m.assert_called_once_with('Raistlin', class_='mage', gift=12)
+    E       assert {'class_': 'mag', 'gift': 12} == {'class_': 'mage', 'gift': 12}
+    E         Omitting 1 identical items, use -v to show
+    E         Differing items:
+    E         {'class_': 'mag'} != {'class_': 'mage'}
+    E         Use -v to get the full diff
+
+
+This is useful when asserting mock calls with many/nested arguments and trying
+to quickly see the difference.
+
+This feature is probably safe, but if you encounter any problems it can be disabled in
+your ``pytest.ini`` file:
+
+.. code-block:: ini
+
+    [pytest]
+    mock_traceback_monkeypatch = false
+
+Note that this feature is automatically disabled with the ``--tb=native`` option. The underlying
+mechanism used to suppress traceback entries from ``mock`` module does not work with that option
+anyway plus it generates confusing messages on Python 3.5 due to exception chaining
+
+.. _advanced assertions: https://pytest.org/latest/assert.html
 
-The old fixture ``mock`` still works, but its use is discouraged and will be
-removed in version ``1.0``.
 
 Requirements
 ============
 
-* Python 2.6+, Python 3.2+
+* Python 2.6+, Python 3.3+
 * pytest
-* mock (for Python < 3.3)
+* mock (for Python 2)
 
 
 Install
@@ -155,19 +165,21 @@ Install
 Install using `pip <http://pip-installer.org/>`_:
 
 .. code-block:: console
-    
+
     $ pip install pytest-mock
 
 Changelog
 =========
 
-Please consult `releases <https://github.com/pytest-dev/pytest-mock/releases>`_.
-        
+Please consult the `changelog page`_.
+
+.. _changelog page: https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst
+
 Why bother with a plugin?
 =========================
 
-There are a number of different ``patch`` usages in the standard ``mock`` API, 
-but IMHO they don't scale very well when you have more than one or two 
+There are a number of different ``patch`` usages in the standard ``mock`` API,
+but IMHO they don't scale very well when you have more than one or two
 patches to apply.
 
 It may lead to an excessive nesting of ``with`` statements, breaking the flow
@@ -176,21 +188,21 @@ of the test:
 .. code-block:: python
 
     import mock
-    
+
     def test_unix_fs():
         with mock.patch('os.remove'):
             UnixFS.rm('file')
             os.remove.assert_called_once_with('file')
-            
+
             with mock.patch('os.listdir'):
                 assert UnixFS.ls('dir') == expected
                 # ...
-                
+
         with mock.patch('shutil.copy'):
             UnixFS.cp('src', 'dst')
             # ...
-            
-        
+
+
 One can use ``patch`` as a decorator to improve the flow of the test:
 
 .. code-block:: python
@@ -201,18 +213,46 @@ One can use ``patch`` as a decorator to improve the flow of the test:
     def test_unix_fs(mocked_copy, mocked_listdir, mocked_remove):
         UnixFS.rm('file')
         os.remove.assert_called_once_with('file')
-        
+
         assert UnixFS.ls('dir') == expected
         # ...
-                
+
         UnixFS.cp('src', 'dst')
         # ...
-        
-But this poses a few disadvantages:        
 
-- test functions must receive the mock objects as parameter, even if you don't plan to 
-  access them directly; also, order depends on the order of the decorated ``patch`` 
+But this poses a few disadvantages:
+
+- test functions must receive the mock objects as parameter, even if you don't plan to
+  access them directly; also, order depends on the order of the decorated ``patch``
   functions;
 - receiving the mocks as parameters doesn't mix nicely with pytest's approach of
   naming fixtures as parameters, or ``pytest.mark.parametrize``;
 - you can't easily undo the mocking during the test execution;
+
+
+**Note**
+
+Although mocker's API is intentionally the same as ``mock.patch``'s, its uses as context managers and function decorators are **not** supported. The purpose of this plugin is to make the use of context managers and function decorators for mocking unnecessary. Indeed, trying to use the functionality in ``mocker`` in this manner can lead to non-intuitive errors:
+
+.. code-block:: python
+
+    def test_context_manager(mocker):
+        a = A()
+        with mocker.patch.object(a, 'doIt', return_value=True, autospec=True):
+            assert a.doIt() == True
+
+.. code-block:: console
+
+    ================================== FAILURES ===================================
+    ____________________________ test_context_manager _____________________________
+    in test_context_manager
+        with mocker.patch.object(a, 'doIt', return_value=True, autospec=True):
+    E   AttributeError: __exit__
+
+
+License
+=======
+
+Distributed under the terms of the `MIT`_ license.
+
+.. _MIT: https://github.com/pytest-dev/pytest-mock/blob/master/LICENSE
diff --git a/PKG-INFO b/pytest_mock.egg-info/PKG-INFO
similarity index 57%
copy from PKG-INFO
copy to pytest_mock.egg-info/PKG-INFO
index 47b3137..1ee9ff6 100644
--- a/PKG-INFO
+++ b/pytest_mock.egg-info/PKG-INFO
@@ -1,55 +1,56 @@
 Metadata-Version: 1.1
 Name: pytest-mock
-Version: 0.8.1
+Version: 1.1
 Summary: Thin-wrapper around the mock package for easier use with py.test
 Home-page: https://github.com/pytest-dev/pytest-mock/
 Author: Bruno Oliveira
 Author-email: nicoddemus at gmail.com
-License: LGPL
+License: MIT
 Description: ===========
         pytest-mock
         ===========
         
         This plugin installs a ``mocker`` fixture which is a thin-wrapper around the patching API
-        provided by the excellent `mock <http://pypi.python.org/pypi/mock>`_ package,
+        provided by the `mock package <http://pypi.python.org/pypi/mock>`_,
         but with the benefit of not having to worry about undoing patches at the end
         of a test:
         
         .. code-block:: python
         
-         
+        
             def test_unix_fs(mocker):
                 mocker.patch('os.remove')
                 UnixFS.rm('file')
                 os.remove.assert_called_once_with('file')
-                
+        
         
         .. Using PNG badges because PyPI doesn't support SVG
         
-        |python| |version| |downloads| |ci| |coverage|
+        |python| |version| |downloads| |ci| |appveyor| |coverage|
         
         .. |version| image:: http://img.shields.io/pypi/v/pytest-mock.png
           :target: https://pypi.python.org/pypi/pytest-mock
-          
+        
         .. |downloads| image:: http://img.shields.io/pypi/dm/pytest-mock.png
           :target: https://pypi.python.org/pypi/pytest-mock
         
         .. |ci| image:: http://img.shields.io/travis/pytest-dev/pytest-mock.png
           :target: https://travis-ci.org/pytest-dev/pytest-mock
         
+        .. |appveyor| image:: https://ci.appveyor.com/api/projects/status/pid1t7iuwhkm9eh6/branch/master?svg=true
+          :target: https://ci.appveyor.com/project/pytestbot/pytest-mock
+        
         .. |coverage| image:: http://img.shields.io/coveralls/pytest-dev/pytest-mock.png
           :target: https://coveralls.io/r/pytest-dev/pytest-mock
         
-        .. |python| image:: https://pypip.in/py_versions/pytest-mock/badge.png
+        .. |python| image:: https://img.shields.io/pypi/pyversions/pytest-mock.svg
           :target: https://pypi.python.org/pypi/pytest-mock/
-          :alt: Supported Python versions
-        
         
         Usage
         =====
         
         The ``mocker`` fixture has the same API as
-        `mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators>`_, 
+        `mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators>`_,
         supporting the same arguments:
         
         .. code-block:: python
@@ -59,54 +60,31 @@ Description: ===========
                 mocker.patch('os.remove')
                 mocker.patch.object(os, 'listdir', autospec=True)
                 mocked_isfile = mocker.patch('os.path.isfile')
-            
+        
         The supported methods are:
-            
+        
         * ``mocker.patch``: see http://www.voidspace.org.uk/python/mock/patch.html#patch.
         * ``mocker.patch.object``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-object.
         * ``mocker.patch.multiple``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-multiple.
         * ``mocker.patch.dict``: see http://www.voidspace.org.uk/python/mock/patch.html#patch-dict.
-        * ``mocker.stopall()``: stops all active patches at this point.
+        * ``mocker.stopall()``: stops all active patches up to this point.
+        * ``mocker.resetall()``: calls ``reset_mock()`` in all mocked objects up to this point. 
         
-        Note that, although mocker's API is intentionally the same as ``mock.patch``'s, its uses as context managers and function decorators are **not** supported. The purpose of this plugin is to make the use of context managers and function decorators for mocking unnecessary. Indeed, trying to use the functionality in ``mocker`` in this manner can lead to non-intuitive errors:
+        Some objects from the ``mock`` module are accessible directly from ``mocker`` for convenience:
         
-        .. code-block:: python
+        * `Mock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock>`_
+        * `MagicMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.MagicMock>`_
+        * `PropertyMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.PropertyMock>`_
+        * `ANY <https://docs.python.org/3/library/unittest.mock.html#any>`_
+        * `call <https://docs.python.org/3/library/unittest.mock.html#call>`_ *(Version 1.1)*
         
-            def test_context_manager(mocker):
-                a = A()
-                with mocker.patch.object(a, 'doIt', return_value=True, autospec=True):
-                    assert a.doIt() == True
-        
-        .. code-block:: console
-        
-            ================================== FAILURES ===================================
-            ____________________________ test_context_manager _____________________________
-            in test_context_manager
-                with mocker.patch.object(a, 'doIt', return_value=True, autospec=True):
-            E   AttributeError: __exit__
-        
-        
-        You can also access ``Mock`` and ``MagicMock`` directly using from ``mocker``
-        fixture:
-        
-        .. code-block:: python
-        
-            def test_feature(mocker):
-                ret = [mocker.Mock(return_value=True), mocker.Mock(return_value=True)]
-                mocker.patch('mylib.func', side_effect=ret)
-        
-        *New in version 0.5*
... 892 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pytest-mock.git



More information about the Python-modules-commits mailing list