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

Vincent Bernat bernat at moszumanska.debian.org
Tue Nov 1 19:09:34 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 cc3055ebc382be373ea9f1bc593cffcd6980f178
Author: Vincent Bernat <bernat at debian.org>
Date:   Tue Nov 1 20:01:57 2016 +0100

    Import pytest-mock_1.3.0.orig.tar.gz
---
 .gitignore                         |   58 +++
 .travis.yml                        |   25 +
 CHANGELOG.rst                      |  214 ++++++++
 LICENSE                            |   40 +-
 MANIFEST.in                        |    2 +-
 PKG-INFO                           |  566 ++++++++++----------
 README.rst                         |  519 +++++++++----------
 _pytest_mock_version.py            |    4 +
 appveyor.yml                       |    7 +
 pytest_mock.egg-info/PKG-INFO      |  566 ++++++++++----------
 pytest_mock.egg-info/SOURCES.txt   |    6 +
 pytest_mock.egg-info/top_level.txt |    1 +
 pytest_mock.py                     |  522 +++++++++----------
 setup.cfg                          |   16 +-
 setup.py                           |   88 ++--
 test_pytest_mock.py                | 1000 ++++++++++++++++++------------------
 tox.ini                            |   24 +
 17 files changed, 2003 insertions(+), 1655 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..da57959
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,58 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+bin/
+build/
+develop-eggs/
+dist/
+eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg*
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.cache
+nosetests.xml
+coverage.xml
+
+# Translations
+*.mo
+
+# Mr Developer
+.mr.developer.cfg
+.project
+.pydevproject
+
+# Rope
+.ropeproject
+
+# Django stuff:
+*.log
+*.pot
+
+# Sphinx documentation
+docs/_build/
+
+# Virtual Envs
+.env*
+
+_pytest_mock_version.py
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..46396d4
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,25 @@
+language: python
+python:
+  - "3.5"
+  - "3.6-dev"
+
+install:
+  - pip install tox coveralls
+
+script:
+  - if [[ $TRAVIS_PYTHON_VERSION != 3.6-dev ]]; then tox; fi
+  - if [[ $TRAVIS_PYTHON_VERSION == 3.6-dev ]]; then tox -e py36-pytest28,py36-pytest29,py36-pytest30; fi
+
+after_success:
+  - coveralls
+
+deploy:
+  provider: pypi
+  user: nicoddemus
+  password:
+    secure: bB4adUZVIkt31cmNklskyIDNehujKToGnStnlunp7P8CBF6CGeNqkYU17emAPvfZbTb/ClUpiO9r6AD1ej32Uyr+I8qUyhuYtHG3JGp+WRR/tw+ytAZIJ9i+PMjBv1RAdyLENJ/Tx0LKHKsABr8dQIieLFqKZJuT77f/5ZkvI/U=
+  on:
+    tags: true
+    distributions: sdist bdist_wheel
+    repo: pytest-dev/pytest-mock
+    condition: $TRAVIS_PYTHON_VERSION = 3.5
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
new file mode 100644
index 0000000..09beec4
--- /dev/null
+++ b/CHANGELOG.rst
@@ -0,0 +1,214 @@
+1.3
+---
+
+* Add support for Python 3.6. Thanks `@hackebrot`_ for the report (`#59`_).
+
+* ``mock.mock_open`` is now aliased as ``mocker.mock_open`` for convenience.
+  Thanks `@pokidovea`_ for the PR (`#66`_).
+
+.. _ at hackebrot: https://github.com/hackebrot
+.. _ at pokidovea: https://github.com/pokidovea
+.. _#59: https://github.com/pytest-dev/pytest-mock/issues/59
+.. _#66: https://github.com/pytest-dev/pytest-mock/pull/66
+
+1.2
+---
+
+* Try to import ``mock`` first instead of ``unittest.mock``. This gives the user flexibility
+  to install a newer ``mock`` version from PyPI instead of using the one available in the
+  Python distribution.
+  Thanks `@wcooley`_ for the PR (`#54`_).
+
+* ``mock.sentinel`` is now aliased as ``mocker.sentinel`` for convenience.
+  Thanks `@kjwilcox`_ for the PR (`#56`_).
+
+.. _ at wcooley: https://github.com/wcooley
+.. _ at kjwilcox: https://github.com/kjwilcox
+.. _#54: https://github.com/pytest-dev/pytest-mock/issues/54
+.. _#56: https://github.com/pytest-dev/pytest-mock/pull/56
+
+1.1
+---
+
+* From this version onward, ``pytest-mock`` is licensed under the `MIT`_ license (`#45`_).
+
+* Now the plugin also adds introspection information on differing call arguments when
+  calling helper methods such as ``assert_called_once_with``. The extra introspection
+  information is similar to pytest's and can be disabled with the ``mock_traceback_monkeypatch``
+  option.
+  Thanks `@asfaltboy`_ for the PR (`#36`_).
+
+* ``mocker.stub()`` now allows passing in the name for the constructed `Mock
+  <https://docs.python.org/3/library/unittest.mock.html#the-mock-class>`_
+  object instead of having to set it using the internal ``_mock_name`` attribute
+  directly. This is useful for debugging as the name is used in the mock's
+  ``repr`` string as well as related assertion failure messages.
+  Thanks `@jurko-gospodnetic`_ for the PR (`#40`_).
+
+* Monkey patching ``mock`` module for friendlier tracebacks 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 (`#44`_).
+  Thanks `@blueyed`_ for the report.
+
+* ``mock.call`` is now aliased as ``mocker.call`` for convenience.
+  Thanks `@jhermann`_ for the PR (`#49`_).
+
+.. _ at jurko-gospodnetic: https://github.com/jurko-gospodnetic
+.. _ at asfaltboy: https://github.com/asfaltboy
+.. _ at jhermann: https://github.com/jhermann
+.. _#45: https://github.com/pytest-dev/pytest-mock/issues/45
+.. _#36: https://github.com/pytest-dev/pytest-mock/issues/36
+.. _#40: https://github.com/pytest-dev/pytest-mock/issues/40
+.. _#44: https://github.com/pytest-dev/pytest-mock/issues/44
+.. _#49: https://github.com/pytest-dev/pytest-mock/issues/49
+.. _MIT: https://github.com/pytest-dev/pytest-mock/blob/master/LICENSE
+
+
+1.0
+---
+
+* Fix AttributeError with ``mocker.spy`` when spying on inherited methods
+  (`#42`_). Thanks `@blueyed`_ for the PR.
+
+.. _ at blueyed: https://github.com/blueyed
+.. _#42: https://github.com/pytest-dev/pytest-mock/issues/42
+
+0.11.0
+------
+
+* `PropertyMock <https://docs.python.org/3/library/unittest.mock.html#unittest.mock.PropertyMock>`_
+  is now accessible from ``mocker``.
+  Thanks `@satyrius`_ for the PR (`#32`_).
+
+* Fix regression using one of the ``assert_*`` methods in patched
+  functions which receive a parameter named ``method``.
+  Thanks `@sagarchalise`_ for the report (`#31`_).
+
+.. _ at sagarchalise: https://github.com/sagarchalise
+.. _ at satyrius: https://github.com/satyrius
+.. _#31: https://github.com/pytest-dev/pytest-mock/issues/31
+.. _#32: https://github.com/pytest-dev/pytest-mock/issues/32
+
+0.10.1
+------
+
+* Fix regression in frozen tests due to ``distutils`` import dependency.
+  Thanks `@The-Compiler`_ for the report (`#29`_).
+
+* Fix regression when using ``pytest-mock`` with ``pytest-2.7.X``.
+  Thanks `@akscram`_ for the report (`#28`_).
+
+.. _ at akscram: https://github.com/Chronial
+.. _#28: https://github.com/pytest-dev/pytest-mock/issues/28
+.. _#29: https://github.com/pytest-dev/pytest-mock/issues/29
+
+0.10
+----
+
+* ``pytest-mock`` now monkeypatches the ``mock`` library to improve pytest output
+  for failures of mock call assertions like ``Mock.assert_called_with()``.
+  Thanks to `@Chronial`_ for idea and PR (`#26`_, `#27`_)!
+
+.. _ at Chronial: https://github.com/Chronial
+.. _#26: https://github.com/pytest-dev/pytest-mock/issues/26
+.. _#27: https://github.com/pytest-dev/pytest-mock/issues/27
+
+0.9.0
+-----
+
+* New ``mocker.resetall`` function, which calls ``reset_mock()`` in all mocked
+  objects up to that point. Thanks to `@mathrick`_ for the PR!
+
+0.8.1
+-----
+
+* ``pytest-mock`` is now also available as a wheel. Thanks `@rouge8`_ for the PR!
+
+0.8.0
+-----
+
+* ``mock.ANY`` is now accessible from the mocker fixture (`#17`_), thanks `@tigarmo`_ for the PR!
+
+.. _#17: https://github.com/pytest-dev/pytest-qt/issues/17
+
+0.7.0
+-----
+
+Thanks to `@fogo`_, mocker.spy can now prey upon staticmethods and classmethods. :smile:
+
+0.6.0
+-----
+
+* Two new auxiliary methods, ``spy`` and ``stub``. See ``README`` for usage.
+  (Thanks `@fogo`_ for complete PR!)
+
+
+0.5.0
+-----
+
+* ``Mock`` and ``MagicMock`` are now accessible from the ``mocker`` fixture,
+  many thanks to `@marcwebbie`_ for the complete PR!
+
+0.4.3
+-----
+
+* ``mocker`` fixture now returns the same object (`#8`_). Many thanks to `@RonnyPfannschmidt`_ for the PR!
+
+.. _#8: https://github.com/pytest-dev/pytest-qt/issues/8
+
+0.4.2
+-----
+
+* Small fix, no longer using wheel as an alternate package since it
+  conditionally depends on mock module based on Python version,
+  as Python >= 3.3 already includes ``unittest.mock``.
+  Many thanks to `@The-Compiler`_ for letting me know and providing a PR with the fix!
+
+0.4.1
+-----
+
+* Small release that just uses ``pytest_mock`` as the name of the plugin,
+  instead of ``pytest-mock``: this makes it simple to depend on this plugin
+  explicitly using ``pytest_plugins`` module variable mechanism.
+
+0.4.0
+-----
+
+* Changed fixture name from ``mock`` into ``mocker`` because it conflicted
+  with the actual mock module, which made using it awkward when access to both
+  the module and the fixture were required within a test.
+
+  Thanks `@kmosher`_ for request and discussion in `#4`_. :smile:
+
+.. _#4: https://github.com/pytest-dev/pytest-qt/issues/4
+
+
+0.3.0
+-----
+
+* Fixed bug `#2`_, where a patch would not be uninstalled correctly after
+  patching the same object twice.
+
+0.2.0
+-----
+
+* Added ``patch.dict`` support.
+
+0.1.0
+-----
+
+First release.
+
+.. _#2: https://github.com/pytest-dev/pytest-qt/issues/2
+
+.. _ at mathrick: https://github.com/mathrick
+.. _ at tigarmo: https://github.com/tigarmo
+.. _ at rouge8: https://github.com/rouge8
+.. _ at fogo: https://github.com/fogo
+.. _ at marcwebbie: https://github.com/marcwebbie
+.. _ at RonnyPfannschmidt: https://github.com/RonnyPfannschmidt
+.. _ at The-Compiler: https://github.com/The-Compiler
+.. _ at kmosher: https://github.com/kmosher
+
+
diff --git a/LICENSE b/LICENSE
index 72a8093..e0550cd 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,21 @@
-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
+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/MANIFEST.in b/MANIFEST.in
index acfb84e..74215c3 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,2 +1,2 @@
-include README.md
+include README.md
 include LICENSE
\ No newline at end of file
diff --git a/PKG-INFO b/PKG-INFO
index 8733eaf..653efb9 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,282 +1,284 @@
-Metadata-Version: 1.1
-Name: pytest-mock
-Version: 1.2
-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: MIT
-Description: ===========
-        pytest-mock
-        ===========
-        
-        This plugin installs a ``mocker`` fixture which is a thin-wrapper around the patching API
-        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| |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://img.shields.io/pypi/pyversions/pytest-mock.svg
-          :target: https://pypi.python.org/pypi/pytest-mock/
-        
-        Usage
-        =====
-        
-        The ``mocker`` fixture has the same API as
-        `mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators>`_,
-        supporting the same arguments:
-        
-        .. code-block:: python
-        
-            def test_foo(mocker):
-                # all valid calls
-                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 up to this point.
-        * ``mocker.resetall()``: calls ``reset_mock()`` in all mocked objects up to this point. 
-        
-        Some objects from the ``mock`` module are accessible directly from ``mocker`` for convenience:
-        
-        * `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)*
-        * `sentinel <https://docs.python.org/3/library/unittest.mock.html#sentinel>`_ *(Version 1.2)*
-        
-        
-        Spy
-        ---
-        
-        The spy acts exactly like the original method in all cases, except it allows use of `mock`
-        features with it, like retrieving call count. It also works for class and static methods.
-        
-        
-        .. code-block:: python
-        
-            def test_spy(mocker):
-                class Foo(object):
-                    def bar(self):
-                        return 42
-        
-                foo = Foo()
-                mocker.spy(foo, 'bar')
-                assert foo.bar() == 42
-                assert foo.bar.call_count == 1
-        
-        Stub
-        ----
-        
-        
-        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
-        
-            def test_stub(mocker):
-                def foo(on_something):
-                    on_something('foo', 'bar')
-        
-                stub = mocker.stub(name='on_something_stub')
-        
-                foo(stub)
-                stub.assert_called_once_with('foo', 'bar')
-        
-        
-        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
-        
-        
-        Requirements
-        ============
-        
-        * Python 2.6+, Python 3.3+
-        * pytest
-        * mock (for Python 2)
-        
-        
-        Install
-        =======
-        
-        Install using `pip <http://pip-installer.org/>`_:
-        
-        .. code-block:: console
-        
-            $ pip install pytest-mock
-        
-        Changelog
-        =========
-        
-        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
-        patches to apply.
-        
-        It may lead to an excessive nesting of ``with`` statements, breaking the flow
-        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
-        
-            @mock.patch('os.remove')
-            @mock.patch('os.listdir')
-            @mock.patch('shutil.copy')
-            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``
-          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 :: 5 - Production/Stable
-Classifier: Framework :: Pytest
-Classifier: Intended Audience :: Developers
-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
+Metadata-Version: 1.1
+Name: pytest-mock
+Version: 1.3.0
+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: MIT
+Description: ===========
+        pytest-mock
+        ===========
+        
+        This plugin installs a ``mocker`` fixture which is a thin-wrapper around the patching API
+        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| |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://img.shields.io/pypi/pyversions/pytest-mock.svg
+          :target: https://pypi.python.org/pypi/pytest-mock/
+        
+        Usage
+        =====
+        
+        The ``mocker`` fixture has the same API as
+        `mock.patch <http://www.voidspace.org.uk/python/mock/patch.html#patch-decorators>`_,
+        supporting the same arguments:
+        
+        .. code-block:: python
+        
+            def test_foo(mocker):
+                # all valid calls
+                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 up to this point.
+        * ``mocker.resetall()``: calls ``reset_mock()`` in all mocked objects up to this point.
+        
+        Some objects from the ``mock`` module are accessible directly from ``mocker`` for convenience:
+        
+        * `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)*
+        * `sentinel <https://docs.python.org/3/library/unittest.mock.html#sentinel>`_ *(Version 1.2)*
+        * `mock_open <https://docs.python.org/3/library/unittest.mock.html#mock-open>`_
+        
+        
+        Spy
+        ---
+        
+        The spy acts exactly like the original method in all cases, except it allows use of `mock`
+        features with it, like retrieving call count. It also works for class and static methods.
+        
+        
+        .. code-block:: python
+        
+            def test_spy(mocker):
+                class Foo(object):
+                    def bar(self):
+                        return 42
+        
+                foo = Foo()
+                mocker.spy(foo, 'bar')
+                assert foo.bar() == 42
+                assert foo.bar.call_count == 1
+        
+        Stub
+        ----
+        
+        
+        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
+        
+            def test_stub(mocker):
+                def foo(on_something):
+                    on_something('foo', 'bar')
+        
+                stub = mocker.stub(name='on_something_stub')
+        
+                foo(stub)
+                stub.assert_called_once_with('foo', 'bar')
+        
+        
+        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
+        
+        
+        Requirements
+        ============
+        
+        * Python 2.6+, Python 3.3+
+        * pytest
+        * mock (for Python 2)
+        
+        
+        Install
+        =======
+        
+        Install using `pip <http://pip-installer.org/>`_:
+        
+        .. code-block:: console
+        
+            $ pip install pytest-mock
+        
+        Changelog
+        =========
+        
+        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
+        patches to apply.
+        
+        It may lead to an excessive nesting of ``with`` statements, breaking the flow
+        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
+        
+            @mock.patch('os.remove')
+            @mock.patch('os.listdir')
+            @mock.patch('shutil.copy')
+            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``
+          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 :: 5 - Production/Stable
+Classifier: Framework :: Pytest
+Classifier: Intended Audience :: Developers
+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: Programming Language :: Python :: 3.6
+Classifier: Topic :: Software Development :: Testing
diff --git a/README.rst b/README.rst
index 31a6bc6..bc87fa4 100644
--- a/README.rst
+++ b/README.rst
@@ -1,259 +1,260 @@
-===========
-pytest-mock
-===========
-
-This plugin installs a ``mocker`` fixture which is a thin-wrapper around the patching API
-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| |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
-
... 2789 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