python/mock-1.0.0/html/changelog.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/python/mock-1.0.0/html/changelog.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,839 @@
     1.4 +
     1.5 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     1.6 +  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     1.7 +
     1.8 +
     1.9 +<html xmlns="http://www.w3.org/1999/xhtml">
    1.10 +  <head>
    1.11 +    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    1.12 +    
    1.13 +    <title>CHANGELOG &mdash; Mock 1.0.0 documentation</title>
    1.14 +    
    1.15 +    <link rel="stylesheet" href="_static/nature.css" type="text/css" />
    1.16 +    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    1.17 +    
    1.18 +    <script type="text/javascript">
    1.19 +      var DOCUMENTATION_OPTIONS = {
    1.20 +        URL_ROOT:    '',
    1.21 +        VERSION:     '1.0.0',
    1.22 +        COLLAPSE_INDEX: false,
    1.23 +        FILE_SUFFIX: '.html',
    1.24 +        HAS_SOURCE:  true
    1.25 +      };
    1.26 +    </script>
    1.27 +    <script type="text/javascript" src="_static/jquery.js"></script>
    1.28 +    <script type="text/javascript" src="_static/underscore.js"></script>
    1.29 +    <script type="text/javascript" src="_static/doctools.js"></script>
    1.30 +    <link rel="top" title="Mock 1.0.0 documentation" href="index.html" />
    1.31 +    <link rel="prev" title="Mock Library Comparison" href="compare.html" /> 
    1.32 +  </head>
    1.33 +  <body>
    1.34 +    <div class="related">
    1.35 +      <h3>Navigation</h3>
    1.36 +      <ul>
    1.37 +        <li class="right" style="margin-right: 10px">
    1.38 +          <a href="genindex.html" title="General Index"
    1.39 +             accesskey="I">index</a></li>
    1.40 +        <li class="right" >
    1.41 +          <a href="compare.html" title="Mock Library Comparison"
    1.42 +             accesskey="P">previous</a> |</li>
    1.43 +        <li><a href="index.html">Mock 1.0.0 documentation</a> &raquo;</li> 
    1.44 +      </ul>
    1.45 +    </div>  
    1.46 +
    1.47 +    <div class="document">
    1.48 +      <div class="documentwrapper">
    1.49 +        <div class="bodywrapper">
    1.50 +          <div class="body">
    1.51 +            
    1.52 +  <div class="section" id="changelog">
    1.53 +<h1>CHANGELOG<a class="headerlink" href="#changelog" title="Permalink to this headline">¶</a></h1>
    1.54 +<div class="section" id="version-1-0-0">
    1.55 +<h2>2012/10/07 Version 1.0.0<a class="headerlink" href="#version-1-0-0" title="Permalink to this headline">¶</a></h2>
    1.56 +<p>No changes since 1.0.0 beta 1. This version has feature parity with
    1.57 +<a class="reference external" href="http://docs.python.org/py3k/library/unittest.mock.html#module-unittest.mock">unittest.mock</a>
    1.58 +in Python 3.3.</p>
    1.59 +<p>Full list of changes since 0.8:</p>
    1.60 +<ul class="simple">
    1.61 +<li><cite>mocksignature</cite>, along with the <cite>mocksignature</cite> argument to <cite>patch</cite>, removed</li>
    1.62 +<li>Support for deleting attributes (accessing deleted attributes will raise an
    1.63 +<cite>AttributeError</cite>)</li>
    1.64 +<li>Added the <cite>mock_open</cite> helper function for mocking the builtin <cite>open</cite></li>
    1.65 +<li><cite>__class__</cite> is assignable, so a mock can pass an <cite>isinstance</cite> check without
    1.66 +requiring a spec</li>
    1.67 +<li>Addition of <cite>PropertyMock</cite>, for mocking properties</li>
    1.68 +<li><cite>MagicMocks</cite> made unorderable by default (in Python 3). The comparison
    1.69 +methods (other than equality and inequality) now return <cite>NotImplemented</cite></li>
    1.70 +<li>Propagate traceback info to support subclassing of <cite>_patch</cite> by other
    1.71 +libraries</li>
    1.72 +<li><cite>create_autospec</cite> works with attributes present in results of <cite>dir</cite> that
    1.73 +can&#8217;t be fetched from the object&#8217;s class. Contributed by Konstantine Rybnikov</li>
    1.74 +<li>Any exceptions in an iterable <cite>side_effect</cite> will be raised instead of
    1.75 +returned</li>
    1.76 +<li>In Python 3, <cite>create_autospec</cite> now supports keyword only arguments</li>
    1.77 +<li>Added <cite>patch.stopall</cite> method to stop all active patches created by <cite>start</cite></li>
    1.78 +<li>BUGFIX: calling <cite>MagicMock.reset_mock</cite> wouldn&#8217;t reset magic method mocks</li>
    1.79 +<li>BUGFIX: calling <cite>reset_mock</cite> on a <cite>MagicMock</cite> created with autospec could
    1.80 +raise an exception</li>
    1.81 +<li>BUGFIX: passing multiple spec arguments to patchers (<cite>spec</cite> , <cite>spec_set</cite> and
    1.82 +<cite>autospec</cite>) had unpredictable results, now it is an error</li>
    1.83 +<li>BUGFIX: using <cite>spec=True</cite> <em>and</em> <cite>create=True</cite> as arguments to patchers could
    1.84 +result in using <cite>DEFAULT</cite> as the spec. Now it is an error instead</li>
    1.85 +<li>BUGFIX: using <cite>spec</cite> or <cite>autospec</cite> arguments to patchers, along with
    1.86 +<cite>spec_set=True</cite> did not work correctly</li>
    1.87 +<li>BUGFIX: using an object that evaluates to False as a spec could be ignored</li>
    1.88 +<li>BUGFIX: a list as the <cite>spec</cite> argument to a patcher would always result in a
    1.89 +non-callable mock. Now if <cite>__call__</cite> is in the spec the mock is callable</li>
    1.90 +</ul>
    1.91 +</div>
    1.92 +<div class="section" id="version-1-0-0-beta-1">
    1.93 +<h2>2012/07/13 Version 1.0.0 beta 1<a class="headerlink" href="#version-1-0-0-beta-1" title="Permalink to this headline">¶</a></h2>
    1.94 +<ul class="simple">
    1.95 +<li>Added <cite>patch.stopall</cite> method to stop all active patches created by <cite>start</cite></li>
    1.96 +<li>BUGFIX: calling <cite>MagicMock.reset_mock</cite> wouldn&#8217;t reset magic method mocks</li>
    1.97 +<li>BUGFIX: calling <cite>reset_mock</cite> on a <cite>MagicMock</cite> created with autospec could
    1.98 +raise an exception</li>
    1.99 +</ul>
   1.100 +</div>
   1.101 +<div class="section" id="version-1-0-0-alpha-2">
   1.102 +<h2>2012/05/04 Version 1.0.0 alpha 2<a class="headerlink" href="#version-1-0-0-alpha-2" title="Permalink to this headline">¶</a></h2>
   1.103 +<ul class="simple">
   1.104 +<li><cite>PropertyMock</cite> attributes are now standard <cite>MagicMocks</cite></li>
   1.105 +<li><cite>create_autospec</cite> works with attributes present in results of <cite>dir</cite> that
   1.106 +can&#8217;t be fetched from the object&#8217;s class. Contributed by Konstantine Rybnikov</li>
   1.107 +<li>Any exceptions in an iterable <cite>side_effect</cite> will be raised instead of
   1.108 +returned</li>
   1.109 +<li>In Python 3, <cite>create_autospec</cite> now supports keyword only arguments</li>
   1.110 +</ul>
   1.111 +</div>
   1.112 +<div class="section" id="version-1-0-0-alpha-1">
   1.113 +<h2>2012/03/25 Version 1.0.0 alpha 1<a class="headerlink" href="#version-1-0-0-alpha-1" title="Permalink to this headline">¶</a></h2>
   1.114 +<p>The standard library version!</p>
   1.115 +<ul class="simple">
   1.116 +<li><cite>mocksignature</cite>, along with the <cite>mocksignature</cite> argument to <cite>patch</cite>, removed</li>
   1.117 +<li>Support for deleting attributes (accessing deleted attributes will raise an
   1.118 +<cite>AttributeError</cite>)</li>
   1.119 +<li>Added the <cite>mock_open</cite> helper function for mocking the builtin <cite>open</cite></li>
   1.120 +<li><cite>__class__</cite> is assignable, so a mock can pass an <cite>isinstance</cite> check without
   1.121 +requiring a spec</li>
   1.122 +<li>Addition of <cite>PropertyMock</cite>, for mocking properties</li>
   1.123 +<li><cite>MagicMocks</cite> made unorderable by default (in Python 3). The comparison
   1.124 +methods (other than equality and inequality) now return <cite>NotImplemented</cite></li>
   1.125 +<li>Propagate traceback info to support subclassing of <cite>_patch</cite> by other
   1.126 +libraries</li>
   1.127 +<li>BUGFIX: passing multiple spec arguments to patchers (<cite>spec</cite> , <cite>spec_set</cite> and
   1.128 +<cite>autospec</cite>) had unpredictable results, now it is an error</li>
   1.129 +<li>BUGFIX: using <cite>spec=True</cite> <em>and</em> <cite>create=True</cite> as arguments to patchers could
   1.130 +result in using <cite>DEFAULT</cite> as the spec. Now it is an error instead</li>
   1.131 +<li>BUGFIX: using <cite>spec</cite> or <cite>autospec</cite> arguments to patchers, along with
   1.132 +<cite>spec_set=True</cite> did not work correctly</li>
   1.133 +<li>BUGFIX: using an object that evaluates to False as a spec could be ignored</li>
   1.134 +<li>BUGFIX: a list as the <cite>spec</cite> argument to a patcher would always result in a
   1.135 +non-callable mock. Now if <cite>__call__</cite> is in the spec the mock is callable</li>
   1.136 +</ul>
   1.137 +</div>
   1.138 +<div class="section" id="version-0-8-0">
   1.139 +<h2>2012/02/13 Version 0.8.0<a class="headerlink" href="#version-0-8-0" title="Permalink to this headline">¶</a></h2>
   1.140 +<p>The only changes since 0.8rc2 are:</p>
   1.141 +<ul class="simple">
   1.142 +<li>Improved repr of <a class="reference internal" href="sentinel.html#mock.sentinel" title="mock.sentinel"><tt class="xref py py-data docutils literal"><span class="pre">sentinel</span></tt></a> objects</li>
   1.143 +<li><a class="reference internal" href="helpers.html#mock.ANY" title="mock.ANY"><tt class="xref py py-data docutils literal"><span class="pre">ANY</span></tt></a> can be used for comparisons against <a class="reference internal" href="helpers.html#mock.call" title="mock.call"><tt class="xref py py-data docutils literal"><span class="pre">call</span></tt></a> objects</li>
   1.144 +<li>The return value of <cite>MagicMock.__iter__</cite> method can be set to
   1.145 +any iterable and isn&#8217;t required to be an iterator</li>
   1.146 +</ul>
   1.147 +<p>Full List of changes since 0.7:</p>
   1.148 +<p>mock 0.8.0 is the last version that will support Python 2.4.</p>
   1.149 +<ul class="simple">
   1.150 +<li>Addition of <a class="reference internal" href="mock.html#mock.Mock.mock_calls" title="mock.Mock.mock_calls"><tt class="xref py py-attr docutils literal"><span class="pre">mock_calls</span></tt></a> list for <em>all</em> calls (including magic
   1.151 +methods and chained calls)</li>
   1.152 +<li><a class="reference internal" href="patch.html#mock.patch" title="mock.patch"><tt class="xref py py-func docutils literal"><span class="pre">patch()</span></tt></a> and <a class="reference internal" href="patch.html#mock.patch.object" title="mock.patch.object"><tt class="xref py py-func docutils literal"><span class="pre">patch.object()</span></tt></a> now create a <a class="reference internal" href="magicmock.html#mock.MagicMock" title="mock.MagicMock"><tt class="xref py py-class docutils literal"><span class="pre">MagicMock</span></tt></a>
   1.153 +instead of a <a class="reference internal" href="mock.html#mock.Mock" title="mock.Mock"><tt class="xref py py-class docutils literal"><span class="pre">Mock</span></tt></a> by default</li>
   1.154 +<li>The patchers (<cite>patch</cite>, <cite>patch.object</cite> and <cite>patch.dict</cite>), plus <cite>Mock</cite> and
   1.155 +<cite>MagicMock</cite>, take arbitrary keyword arguments for configuration</li>
   1.156 +<li>New mock method <a class="reference internal" href="mock.html#mock.Mock.configure_mock" title="mock.Mock.configure_mock"><tt class="xref py py-meth docutils literal"><span class="pre">configure_mock()</span></tt></a> for setting attributes and
   1.157 +return values / side effects on the mock and its attributes</li>
   1.158 +<li>New mock assert methods <a class="reference internal" href="mock.html#mock.Mock.assert_any_call" title="mock.Mock.assert_any_call"><tt class="xref py py-meth docutils literal"><span class="pre">assert_any_call()</span></tt></a> and
   1.159 +<a class="reference internal" href="mock.html#mock.Mock.assert_has_calls" title="mock.Mock.assert_has_calls"><tt class="xref py py-meth docutils literal"><span class="pre">assert_has_calls()</span></tt></a></li>
   1.160 +<li>Implemented <a class="reference internal" href="helpers.html#auto-speccing"><em>Autospeccing</em></a> (recursive, lazy speccing of mocks with
   1.161 +mocked signatures for functions/methods), as the <cite>autospec</cite> argument to
   1.162 +<cite>patch</cite></li>
   1.163 +<li>Added the <a class="reference internal" href="helpers.html#mock.create_autospec" title="mock.create_autospec"><tt class="xref py py-func docutils literal"><span class="pre">create_autospec()</span></tt></a> function for manually creating
   1.164 +&#8216;auto-specced&#8217; mocks</li>
   1.165 +<li><a class="reference internal" href="patch.html#mock.patch.multiple" title="mock.patch.multiple"><tt class="xref py py-func docutils literal"><span class="pre">patch.multiple()</span></tt></a> for doing multiple patches in a single call, using
   1.166 +keyword arguments</li>
   1.167 +<li>Setting <a class="reference internal" href="mock.html#mock.Mock.side_effect" title="mock.Mock.side_effect"><tt class="xref py py-attr docutils literal"><span class="pre">side_effect</span></tt></a> to an iterable will cause calls to the mock
   1.168 +to return the next value from the iterable</li>
   1.169 +<li>New <cite>new_callable</cite> argument to <cite>patch</cite> and <cite>patch.object</cite> allowing you to
   1.170 +pass in a class or callable object (instead of <cite>MagicMock</cite>) that will be
   1.171 +called to replace the object being patched</li>
   1.172 +<li>Addition of <a class="reference internal" href="mock.html#mock.NonCallableMock" title="mock.NonCallableMock"><tt class="xref py py-class docutils literal"><span class="pre">NonCallableMock</span></tt></a> and <a class="reference internal" href="magicmock.html#mock.NonCallableMagicMock" title="mock.NonCallableMagicMock"><tt class="xref py py-class docutils literal"><span class="pre">NonCallableMagicMock</span></tt></a>, mocks
   1.173 +without a <cite>__call__</cite> method</li>
   1.174 +<li>Addition of <a class="reference internal" href="mock.html#mock.Mock.mock_add_spec" title="mock.Mock.mock_add_spec"><tt class="xref py py-meth docutils literal"><span class="pre">mock_add_spec()</span></tt></a> method for adding (or changing) a
   1.175 +spec on an existing mock</li>
   1.176 +<li>Protocol methods on <a class="reference internal" href="magicmock.html#mock.MagicMock" title="mock.MagicMock"><tt class="xref py py-class docutils literal"><span class="pre">MagicMock</span></tt></a> are magic mocks, and are created
   1.177 +lazily on first lookup. This means the result of calling a protocol method is
   1.178 +a <cite>MagicMock</cite> instead of a <cite>Mock</cite> as it was previously</li>
   1.179 +<li>Addition of <a class="reference internal" href="mock.html#mock.Mock.attach_mock" title="mock.Mock.attach_mock"><tt class="xref py py-meth docutils literal"><span class="pre">attach_mock()</span></tt></a> method</li>
   1.180 +<li>Added <a class="reference internal" href="helpers.html#mock.ANY" title="mock.ANY"><tt class="xref py py-data docutils literal"><span class="pre">ANY</span></tt></a> for ignoring arguments in <a class="reference internal" href="mock.html#mock.Mock.assert_called_with" title="mock.Mock.assert_called_with"><tt class="xref py py-meth docutils literal"><span class="pre">assert_called_with()</span></tt></a>
   1.181 +calls</li>
   1.182 +<li>Addition of <a class="reference internal" href="helpers.html#mock.call" title="mock.call"><tt class="xref py py-data docutils literal"><span class="pre">call</span></tt></a> helper object</li>
   1.183 +<li>Improved repr for mocks</li>
   1.184 +<li>Improved repr for <a class="reference internal" href="mock.html#mock.Mock.call_args" title="mock.Mock.call_args"><tt class="xref py py-attr docutils literal"><span class="pre">Mock.call_args</span></tt></a> and entries in
   1.185 +<a class="reference internal" href="mock.html#mock.Mock.call_args_list" title="mock.Mock.call_args_list"><tt class="xref py py-attr docutils literal"><span class="pre">Mock.call_args_list</span></tt></a>, <a class="reference internal" href="mock.html#mock.Mock.method_calls" title="mock.Mock.method_calls"><tt class="xref py py-attr docutils literal"><span class="pre">Mock.method_calls</span></tt></a> and
   1.186 +<a class="reference internal" href="mock.html#mock.Mock.mock_calls" title="mock.Mock.mock_calls"><tt class="xref py py-attr docutils literal"><span class="pre">Mock.mock_calls</span></tt></a></li>
   1.187 +<li>Improved repr for <a class="reference internal" href="sentinel.html#mock.sentinel" title="mock.sentinel"><tt class="xref py py-data docutils literal"><span class="pre">sentinel</span></tt></a> objects</li>
   1.188 +<li><cite>patch</cite> lookup is done at use time not at decoration time</li>
   1.189 +<li>In Python 2.6 or more recent, <cite>dir</cite> on a mock will report all the dynamically
   1.190 +created attributes (or the full list of attributes if there is a spec) as
   1.191 +well as all the mock methods and attributes.</li>
   1.192 +<li>Module level <a class="reference internal" href="helpers.html#mock.FILTER_DIR" title="mock.FILTER_DIR"><tt class="xref py py-data docutils literal"><span class="pre">FILTER_DIR</span></tt></a> added to control whether <cite>dir(mock)</cite> filters
   1.193 +private attributes. <cite>True</cite> by default.</li>
   1.194 +<li><cite>patch.TEST_PREFIX</cite> for controlling how patchers recognise test methods when
   1.195 +used to decorate a class</li>
   1.196 +<li>Support for using Java exceptions as a <a class="reference internal" href="mock.html#mock.Mock.side_effect" title="mock.Mock.side_effect"><tt class="xref py py-attr docutils literal"><span class="pre">side_effect</span></tt></a> on Jython</li>
   1.197 +<li><cite>Mock</cite> call lists (<cite>call_args_list</cite>, <cite>method_calls</cite> &amp; <cite>mock_calls</cite>) are now
   1.198 +custom list objects that allow membership tests for &#8220;sub lists&#8221; and have
   1.199 +a nicer representation if you <cite>str</cite> or <cite>print</cite> them</li>
   1.200 +<li>Mocks attached as attributes or return values to other mocks have calls
   1.201 +recorded in <cite>method_calls</cite> and <cite>mock_calls</cite> of the parent (unless a name is
   1.202 +already set on the child)</li>
   1.203 +<li>Improved failure messages for <cite>assert_called_with</cite> and
   1.204 +<cite>assert_called_once_with</cite></li>
   1.205 +<li>The return value of the <a class="reference internal" href="magicmock.html#mock.MagicMock" title="mock.MagicMock"><tt class="xref py py-class docutils literal"><span class="pre">MagicMock</span></tt></a> <cite>__iter__</cite> method can be set to
   1.206 +any iterable and isn&#8217;t required to be an iterator</li>
   1.207 +<li>Added the Mock API (<cite>assert_called_with</cite> etc) to functions created by
   1.208 +<tt class="xref py py-func docutils literal"><span class="pre">mocksignature()</span></tt></li>
   1.209 +<li>Tuples as well as lists can be used to specify allowed methods for <cite>spec</cite> &amp;
   1.210 +<cite>spec_set</cite> arguments</li>
   1.211 +<li>Calling <cite>stop</cite> on an unstarted patcher fails with  a more meaningful error
   1.212 +message</li>
   1.213 +<li>Renamed the internal classes <cite>Sentinel</cite> and <cite>SentinelObject</cite> to prevent abuse</li>
   1.214 +<li>BUGFIX: an error creating a patch, with nested patch decorators, won&#8217;t leave
   1.215 +patches in place</li>
   1.216 +<li>BUGFIX: <cite>__truediv__</cite> and <cite>__rtruediv__</cite> not available as magic methods on
   1.217 +mocks in Python 3</li>
   1.218 +<li>BUGFIX: <cite>assert_called_with</cite> / <cite>assert_called_once_with</cite> can be used with
   1.219 +<cite>self</cite> as a keyword argument</li>
   1.220 +<li>BUGFIX: when patching a class with an explicit spec / spec_set (not a
   1.221 +boolean) it applies &#8220;spec inheritance&#8221; to the return value of the created
   1.222 +mock (the &#8220;instance&#8221;)</li>
   1.223 +<li>BUGFIX: remove the <cite>__unittest</cite> marker causing traceback truncation</li>
   1.224 +<li>Removal of deprecated <cite>patch_object</cite></li>
   1.225 +<li>Private attributes <cite>_name</cite>, <cite>_methods</cite>, &#8216;_children&#8217;, <cite>_wraps</cite> and <cite>_parent</cite>
   1.226 +(etc) renamed to reduce likelihood of clash with user attributes.</li>
   1.227 +<li>Added license file to the distribution</li>
   1.228 +</ul>
   1.229 +</div>
   1.230 +<div class="section" id="version-0-8-0-release-candidate-2">
   1.231 +<h2>2012/01/10 Version 0.8.0 release candidate 2<a class="headerlink" href="#version-0-8-0-release-candidate-2" title="Permalink to this headline">¶</a></h2>
   1.232 +<ul class="simple">
   1.233 +<li>Removed the <cite>configure</cite> keyword argument to <cite>create_autospec</cite> and allow
   1.234 +arbitrary keyword arguments (for the <cite>Mock</cite> constructor) instead</li>
   1.235 +<li>Fixed <cite>ANY</cite> equality with some types in <cite>assert_called_with</cite> calls</li>
   1.236 +<li>Switched to a standard Sphinx theme (compatible with
   1.237 +<a class="reference external" href="http://mock.readthedocs.org">readthedocs.org</a>)</li>
   1.238 +</ul>
   1.239 +</div>
   1.240 +<div class="section" id="version-0-8-0-release-candidate-1">
   1.241 +<h2>2011/12/29 Version 0.8.0 release candidate 1<a class="headerlink" href="#version-0-8-0-release-candidate-1" title="Permalink to this headline">¶</a></h2>
   1.242 +<ul class="simple">
   1.243 +<li><cite>create_autospec</cite> on the return value of a mocked class will use <cite>__call__</cite>
   1.244 +for the signature rather than <cite>__init__</cite></li>
   1.245 +<li>Performance improvement instantiating <cite>Mock</cite> and <cite>MagicMock</cite></li>
   1.246 +<li>Mocks used as magic methods have the same type as their parent instead of
   1.247 +being hardcoded to <cite>MagicMock</cite></li>
   1.248 +</ul>
   1.249 +<p>Special thanks to Julian Berman for his help with diagnosing and improving
   1.250 +performance in this release.</p>
   1.251 +</div>
   1.252 +<div class="section" id="version-0-8-0-beta-4">
   1.253 +<h2>2011/10/09 Version 0.8.0 beta 4<a class="headerlink" href="#version-0-8-0-beta-4" title="Permalink to this headline">¶</a></h2>
   1.254 +<ul class="simple">
   1.255 +<li><cite>patch</cite> lookup is done at use time not at decoration time</li>
   1.256 +<li>When attaching a Mock to another Mock as a magic method, calls are recorded
   1.257 +in mock_calls</li>
   1.258 +<li>Addition of <cite>attach_mock</cite> method</li>
   1.259 +<li>Renamed the internal classes <cite>Sentinel</cite> and <cite>SentinelObject</cite> to prevent abuse</li>
   1.260 +<li>BUGFIX: various issues around circular references with mocks (setting a mock
   1.261 +return value to be itself etc)</li>
   1.262 +</ul>
   1.263 +</div>
   1.264 +<div class="section" id="version-0-8-0-beta-3">
   1.265 +<h2>2011/08/15 Version 0.8.0 beta 3<a class="headerlink" href="#version-0-8-0-beta-3" title="Permalink to this headline">¶</a></h2>
   1.266 +<ul class="simple">
   1.267 +<li>Mocks attached as attributes or return values to other mocks have calls
   1.268 +recorded in <cite>method_calls</cite> and <cite>mock_calls</cite> of the parent (unless a name is
   1.269 +already set on the child)</li>
   1.270 +<li>Addition of <cite>mock_add_spec</cite> method for adding (or changing) a spec on an
   1.271 +existing mock</li>
   1.272 +<li>Improved repr for <cite>Mock.call_args</cite> and entries in <cite>Mock.call_args_list</cite>,
   1.273 +<cite>Mock.method_calls</cite> and <cite>Mock.mock_calls</cite></li>
   1.274 +<li>Improved repr for mocks</li>
   1.275 +<li>BUGFIX: minor fixes in the way <cite>mock_calls</cite> is worked out,
   1.276 +especially for &#8220;intermediate&#8221; mocks in a call chain</li>
   1.277 +</ul>
   1.278 +</div>
   1.279 +<div class="section" id="version-0-8-0-beta-2">
   1.280 +<h2>2011/08/05 Version 0.8.0 beta 2<a class="headerlink" href="#version-0-8-0-beta-2" title="Permalink to this headline">¶</a></h2>
   1.281 +<ul class="simple">
   1.282 +<li>Setting <cite>side_effect</cite> to an iterable will cause calls to the mock to return
   1.283 +the next value from the iterable</li>
   1.284 +<li>Added <cite>assert_any_call</cite> method</li>
   1.285 +<li>Moved <cite>assert_has_calls</cite> from call lists onto mocks</li>
   1.286 +<li>BUGFIX: <cite>call_args</cite> and all members of <cite>call_args_list</cite> are two tuples of
   1.287 +<cite>(args, kwargs)</cite> again instead of three tuples of <cite>(name, args, kwargs)</cite></li>
   1.288 +</ul>
   1.289 +</div>
   1.290 +<div class="section" id="version-0-8-0-beta-1">
   1.291 +<h2>2011/07/25 Version 0.8.0 beta 1<a class="headerlink" href="#version-0-8-0-beta-1" title="Permalink to this headline">¶</a></h2>
   1.292 +<ul class="simple">
   1.293 +<li><cite>patch.TEST_PREFIX</cite> for controlling how patchers recognise test methods when
   1.294 +used to decorate a class</li>
   1.295 +<li><cite>Mock</cite> call lists (<cite>call_args_list</cite>, <cite>method_calls</cite> &amp; <cite>mock_calls</cite>) are now
   1.296 +custom list objects that allow membership tests for &#8220;sub lists&#8221; and have
   1.297 +an <cite>assert_has_calls</cite> method for unordered call checks</li>
   1.298 +<li><cite>callargs</cite> changed to <em>always</em> be a three-tuple of <cite>(name, args, kwargs)</cite></li>
   1.299 +<li>Addition of <cite>mock_calls</cite> list for <em>all</em> calls (including magic methods and
   1.300 +chained calls)</li>
   1.301 +<li>Extension of <cite>call</cite> object to support chained calls and <cite>callargs</cite> for better
   1.302 +comparisons with or without names. <cite>call</cite> object has a <cite>call_list</cite> method for
   1.303 +chained calls</li>
   1.304 +<li>Added the public <cite>instance</cite> argument to <cite>create_autospec</cite></li>
   1.305 +<li>Support for using Java exceptions as a <cite>side_effect</cite> on Jython</li>
   1.306 +<li>Improved failure messages for <cite>assert_called_with</cite> and
   1.307 +<cite>assert_called_once_with</cite></li>
   1.308 +<li>Tuples as well as lists can be used to specify allowed methods for <cite>spec</cite> &amp;
   1.309 +<cite>spec_set</cite> arguments</li>
   1.310 +<li>BUGFIX: Fixed bug in <cite>patch.multiple</cite> for argument passing when creating
   1.311 +mocks</li>
   1.312 +<li>Added license file to the distribution</li>
   1.313 +</ul>
   1.314 +</div>
   1.315 +<div class="section" id="version-0-8-0-alpha-2">
   1.316 +<h2>2011/07/16 Version 0.8.0 alpha 2<a class="headerlink" href="#version-0-8-0-alpha-2" title="Permalink to this headline">¶</a></h2>
   1.317 +<ul class="simple">
   1.318 +<li><cite>patch.multiple</cite> for doing multiple patches in a single call, using keyword
   1.319 +arguments</li>
   1.320 +<li>New <cite>new_callable</cite> argument to <cite>patch</cite> and <cite>patch.object</cite> allowing you to
   1.321 +pass in a class or callable object (instead of <cite>MagicMock</cite>) that will be
   1.322 +called to replace the object being patched</li>
   1.323 +<li>Addition of <cite>NonCallableMock</cite> and <cite>NonCallableMagicMock</cite>, mocks without a
   1.324 +<cite>__call__</cite> method</li>
   1.325 +<li>Mocks created by <cite>patch</cite> have a <cite>MagicMock</cite> as the <cite>return_value</cite> where a
   1.326 +class is being patched</li>
   1.327 +<li><cite>create_autospec</cite> can create non-callable mocks for non-callable objects.
   1.328 +<cite>return_value</cite> mocks of classes will be non-callable unless the class has
   1.329 +a <cite>__call__</cite> method</li>
   1.330 +<li><cite>autospec</cite> creates a <cite>MagicMock</cite> without a spec for properties and slot
   1.331 +descriptors, because we don&#8217;t know the type of object they return</li>
   1.332 +<li>Removed the &#8220;inherit&#8221; argument from <cite>create_autospec</cite></li>
   1.333 +<li>Calling <cite>stop</cite> on an unstarted patcher fails with  a more meaningful error
   1.334 +message</li>
   1.335 +<li>BUGFIX: an error creating a patch, with nested patch decorators, won&#8217;t leave
   1.336 +patches in place</li>
   1.337 +<li>BUGFIX: <cite>__truediv__</cite> and <cite>__rtruediv__</cite> not available as magic methods on
   1.338 +mocks in Python 3</li>
   1.339 +<li>BUGFIX: <cite>assert_called_with</cite> / <cite>assert_called_once_with</cite> can be used with
   1.340 +<cite>self</cite> as a keyword argument</li>
   1.341 +<li>BUGFIX: autospec for functions / methods with an argument named self that
   1.342 +isn&#8217;t the first argument no longer broken</li>
   1.343 +<li>BUGFIX: when patching a class with an explicit spec / spec_set (not a
   1.344 +boolean) it applies &#8220;spec inheritance&#8221; to the return value of the created
   1.345 +mock (the &#8220;instance&#8221;)</li>
   1.346 +<li>BUGFIX: remove the <cite>__unittest</cite> marker causing traceback truncation</li>
   1.347 +</ul>
   1.348 +</div>
   1.349 +<div class="section" id="version-0-8-0-alpha-1">
   1.350 +<h2>2011/06/14 Version 0.8.0 alpha 1<a class="headerlink" href="#version-0-8-0-alpha-1" title="Permalink to this headline">¶</a></h2>
   1.351 +<p>mock 0.8.0 is the last version that will support Python 2.4.</p>
   1.352 +<ul>
   1.353 +<li><p class="first">The patchers (<cite>patch</cite>, <cite>patch.object</cite> and <cite>patch.dict</cite>), plus <cite>Mock</cite> and
   1.354 +<cite>MagicMock</cite>, take arbitrary keyword arguments for configuration</p>
   1.355 +</li>
   1.356 +<li><p class="first">New mock method <cite>configure_mock</cite> for setting attributes and return values /
   1.357 +side effects on the mock and its attributes</p>
   1.358 +</li>
   1.359 +<li><p class="first">In Python 2.6 or more recent, <cite>dir</cite> on a mock will report all the dynamically
   1.360 +created attributes (or the full list of attributes if there is a spec) as
   1.361 +well as all the mock methods and attributes.</p>
   1.362 +</li>
   1.363 +<li><p class="first">Module level <cite>FILTER_DIR</cite> added to control whether <cite>dir(mock)</cite> filters
   1.364 +private attributes. <cite>True</cite> by default. Note that <cite>vars(Mock())</cite> can still be
   1.365 +used to get all instance attributes and <cite>dir(type(Mock())</cite> will still return
   1.366 +all the other attributes (irrespective of <cite>FILTER_DIR</cite>)</p>
   1.367 +</li>
   1.368 +<li><p class="first"><cite>patch</cite> and <cite>patch.object</cite> now create a <cite>MagicMock</cite> instead of a <cite>Mock</cite> by
   1.369 +default</p>
   1.370 +</li>
   1.371 +<li><p class="first">Added <cite>ANY</cite> for ignoring arguments in <cite>assert_called_with</cite> calls</p>
   1.372 +</li>
   1.373 +<li><p class="first">Addition of <cite>call</cite> helper object</p>
   1.374 +</li>
   1.375 +<li><p class="first">Protocol methods on <cite>MagicMock</cite> are magic mocks, and are created lazily on
   1.376 +first lookup. This means the result of calling a protocol method is a
   1.377 +MagicMock instead of a Mock as it was previously</p>
   1.378 +</li>
   1.379 +<li><p class="first">Added the Mock API (<cite>assert_called_with</cite> etc) to functions created by
   1.380 +<cite>mocksignature</cite></p>
   1.381 +</li>
   1.382 +<li><p class="first">Private attributes <cite>_name</cite>, <cite>_methods</cite>, &#8216;_children&#8217;, <cite>_wraps</cite> and <cite>_parent</cite>
   1.383 +(etc) renamed to reduce likelihood of clash with user attributes.</p>
   1.384 +</li>
   1.385 +<li><p class="first">Implemented auto-speccing (recursive, lazy speccing of mocks with mocked
   1.386 +signatures for functions/methods)</p>
   1.387 +<p>Limitations:</p>
   1.388 +<ul class="simple">
   1.389 +<li>Doesn&#8217;t mock magic methods or attributes (it creates MagicMocks, so the
   1.390 +magic methods are <em>there</em>, they just don&#8217;t have the signature mocked nor
   1.391 +are attributes followed)</li>
   1.392 +<li>Doesn&#8217;t mock function / method attributes</li>
   1.393 +<li>Uses object traversal on the objects being mocked to determine types - so
   1.394 +properties etc may be triggered</li>
   1.395 +<li>The return value of mocked classes (the &#8216;instance&#8217;) has the same call
   1.396 +signature as the class __init__ (as they share the same spec)</li>
   1.397 +</ul>
   1.398 +<p>You create auto-specced mocks by passing <cite>autospec=True</cite> to <cite>patch</cite>.</p>
   1.399 +<p>Note that attributes that are None are special cased and mocked without a
   1.400 +spec (so any attribute / method can be used). This is because None is
   1.401 +typically used as a default value for attributes that may be of some other
   1.402 +type, and as we don&#8217;t know what type that may be we allow all access.</p>
   1.403 +<p>Note that the <cite>autospec</cite> option to <cite>patch</cite> obsoletes the <cite>mocksignature</cite>
   1.404 +option.</p>
   1.405 +</li>
   1.406 +<li><p class="first">Added the <cite>create_autospec</cite> function for manually creating &#8216;auto-specced&#8217;
   1.407 +mocks</p>
   1.408 +</li>
   1.409 +<li><p class="first">Removal of deprecated <cite>patch_object</cite></p>
   1.410 +</li>
   1.411 +</ul>
   1.412 +</div>
   1.413 +<div class="section" id="version-0-7-2">
   1.414 +<h2>2011/05/30 Version 0.7.2<a class="headerlink" href="#version-0-7-2" title="Permalink to this headline">¶</a></h2>
   1.415 +<ul class="simple">
   1.416 +<li>BUGFIX: instances of list subclasses can now be used as mock specs</li>
   1.417 +<li>BUGFIX: MagicMock equality / inequality protocol methods changed to use the
   1.418 +default equality / inequality. This is done through a <cite>side_effect</cite> on
   1.419 +the mocks used for <cite>__eq__</cite> / <cite>__ne__</cite></li>
   1.420 +</ul>
   1.421 +</div>
   1.422 +<div class="section" id="version-0-7-1">
   1.423 +<h2>2011/05/06 Version 0.7.1<a class="headerlink" href="#version-0-7-1" title="Permalink to this headline">¶</a></h2>
   1.424 +<p>Package fixes contributed by Michael Fladischer. No code changes.</p>
   1.425 +<ul class="simple">
   1.426 +<li>Include template in package</li>
   1.427 +<li>Use isolated binaries for the tox tests</li>
   1.428 +<li>Unset executable bit on docs</li>
   1.429 +<li>Fix DOS line endings in getting-started.txt</li>
   1.430 +</ul>
   1.431 +</div>
   1.432 +<div class="section" id="version-0-7-0">
   1.433 +<h2>2011/03/05 Version 0.7.0<a class="headerlink" href="#version-0-7-0" title="Permalink to this headline">¶</a></h2>
   1.434 +<p>No API changes since 0.7.0 rc1. Many documentation changes including a stylish
   1.435 +new <a class="reference external" href="https://github.com/coordt/ADCtheme/">Sphinx theme</a>.</p>
   1.436 +<p>The full set of changes since 0.6.0 are:</p>
   1.437 +<ul class="simple">
   1.438 +<li>Python 3 compatibility</li>
   1.439 +<li>Ability to mock magic methods with <cite>Mock</cite> and addition of <cite>MagicMock</cite>
   1.440 +with pre-created magic methods</li>
   1.441 +<li>Addition of <cite>mocksignature</cite> and <cite>mocksignature</cite> argument to <cite>patch</cite> and
   1.442 +<cite>patch.object</cite></li>
   1.443 +<li>Addition of <cite>patch.dict</cite> for changing dictionaries during a test</li>
   1.444 +<li>Ability to use <cite>patch</cite>, <cite>patch.object</cite> and <cite>patch.dict</cite> as class decorators</li>
   1.445 +<li>Renamed <tt class="docutils literal"><span class="pre">patch_object</span></tt> to <cite>patch.object</cite> (<tt class="docutils literal"><span class="pre">patch_object</span></tt> is
   1.446 +deprecated)</li>
   1.447 +<li>Addition of soft comparisons: <cite>call_args</cite>, <cite>call_args_list</cite> and <cite>method_calls</cite>
   1.448 +now return tuple-like objects which compare equal even when empty args
   1.449 +or kwargs are skipped</li>
   1.450 +<li>patchers (<cite>patch</cite>, <cite>patch.object</cite> and <cite>patch.dict</cite>) have start and stop
   1.451 +methods</li>
   1.452 +<li>Addition of <cite>assert_called_once_with</cite> method</li>
   1.453 +<li>Mocks can now be named (<cite>name</cite> argument to constructor) and the name is used
   1.454 +in the repr</li>
   1.455 +<li>repr of a mock with a spec includes the class name of the spec</li>
   1.456 +<li><cite>assert_called_with</cite> works with <cite>python -OO</cite></li>
   1.457 +<li>New <cite>spec_set</cite> keyword argument to <cite>Mock</cite> and <cite>patch</cite>. If used,
   1.458 +attempting to <em>set</em> an attribute on a mock not on the spec will raise an
   1.459 +<cite>AttributeError</cite></li>
   1.460 +<li>Mocks created with a spec can now pass <cite>isinstance</cite> tests (<cite>__class__</cite>
   1.461 +returns the type of the spec)</li>
   1.462 +<li>Added docstrings to all objects</li>
   1.463 +<li>Improved failure message for <cite>Mock.assert_called_with</cite> when the mock
   1.464 +has not been called at all</li>
   1.465 +<li>Decorated functions / methods have their docstring and <cite>__module__</cite>
   1.466 +preserved on Python 2.4.</li>
   1.467 +<li>BUGFIX: <cite>mock.patch</cite> now works correctly with certain types of objects that
   1.468 +proxy attribute access, like the django settings object</li>
   1.469 +<li>BUGFIX: mocks are now copyable (thanks to Ned Batchelder for reporting and
   1.470 +diagnosing this)</li>
   1.471 +<li>BUGFIX: <cite>spec=True</cite> works with old style classes</li>
   1.472 +<li>BUGFIX: <tt class="docutils literal"><span class="pre">help(mock)</span></tt> works now (on the module). Can no longer use <tt class="docutils literal"><span class="pre">__bases__</span></tt>
   1.473 +as a valid sentinel name (thanks to Stephen Emslie for reporting and
   1.474 +diagnosing this)</li>
   1.475 +<li>BUGFIX: <tt class="docutils literal"><span class="pre">side_effect</span></tt> now works with <tt class="docutils literal"><span class="pre">BaseException</span></tt> exceptions like
   1.476 +<tt class="docutils literal"><span class="pre">KeyboardInterrupt</span></tt></li>
   1.477 +<li>BUGFIX: <cite>reset_mock</cite> caused infinite recursion when a mock is set as its own
   1.478 +return value</li>
   1.479 +<li>BUGFIX: patching the same object twice now restores the patches correctly</li>
   1.480 +<li>with statement tests now skipped on Python 2.4</li>
   1.481 +<li>Tests require unittest2 (or unittest2-py3k) to run</li>
   1.482 +<li>Tested with <a class="reference external" href="http://pypi.python.org/pypi/tox">tox</a> on Python 2.4 - 3.2,
   1.483 +jython and pypy (excluding 3.0)</li>
   1.484 +<li>Added &#8216;build_sphinx&#8217; command to setup.py (requires setuptools or distribute)
   1.485 +Thanks to Florian Bauer</li>
   1.486 +<li>Switched from subversion to mercurial for source code control</li>
   1.487 +<li><a class="reference external" href="http://konryd.blogspot.com/">Konrad Delong</a> added as co-maintainer</li>
   1.488 +</ul>
   1.489 +</div>
   1.490 +<div class="section" id="version-0-7-0-rc-1">
   1.491 +<h2>2011/02/16 Version 0.7.0 RC 1<a class="headerlink" href="#version-0-7-0-rc-1" title="Permalink to this headline">¶</a></h2>
   1.492 +<p>Changes since beta 4:</p>
   1.493 +<ul class="simple">
   1.494 +<li>Tested with jython, pypy and Python 3.2 and 3.1</li>
   1.495 +<li>Decorated functions / methods have their docstring and <cite>__module__</cite>
   1.496 +preserved on Python 2.4</li>
   1.497 +<li>BUGFIX: <cite>mock.patch</cite> now works correctly with certain types of objects that
   1.498 +proxy attribute access, like the django settings object</li>
   1.499 +<li>BUGFIX: <cite>reset_mock</cite> caused infinite recursion when a mock is set as its own
   1.500 +return value</li>
   1.501 +</ul>
   1.502 +</div>
   1.503 +<div class="section" id="version-0-7-0-beta-4">
   1.504 +<h2>2010/11/12 Version 0.7.0 beta 4<a class="headerlink" href="#version-0-7-0-beta-4" title="Permalink to this headline">¶</a></h2>
   1.505 +<ul class="simple">
   1.506 +<li>patchers (<cite>patch</cite>, <cite>patch.object</cite> and <cite>patch.dict</cite>) have start and stop
   1.507 +methods</li>
   1.508 +<li>Addition of <cite>assert_called_once_with</cite> method</li>
   1.509 +<li>repr of a mock with a spec includes the class name of the spec</li>
   1.510 +<li><cite>assert_called_with</cite> works with <cite>python -OO</cite></li>
   1.511 +<li>New <cite>spec_set</cite> keyword argument to <cite>Mock</cite> and <cite>patch</cite>. If used,
   1.512 +attempting to <em>set</em> an attribute on a mock not on the spec will raise an
   1.513 +<cite>AttributeError</cite></li>
   1.514 +<li>Attributes and return value of a <cite>MagicMock</cite> are <cite>MagicMock</cite> objects</li>
   1.515 +<li>Attempting to set an unsupported magic method now raises an <cite>AttributeError</cite></li>
   1.516 +<li><cite>patch.dict</cite> works as a class decorator</li>
   1.517 +<li>Switched from subversion to mercurial for source code control</li>
   1.518 +<li>BUGFIX: mocks are now copyable (thanks to Ned Batchelder for reporting and
   1.519 +diagnosing this)</li>
   1.520 +<li>BUGFIX: <cite>spec=True</cite> works with old style classes</li>
   1.521 +<li>BUGFIX: <cite>mocksignature=True</cite> can now patch instance methods via
   1.522 +<cite>patch.object</cite></li>
   1.523 +</ul>
   1.524 +</div>
   1.525 +<div class="section" id="version-0-7-0-beta-3">
   1.526 +<h2>2010/09/18 Version 0.7.0 beta 3<a class="headerlink" href="#version-0-7-0-beta-3" title="Permalink to this headline">¶</a></h2>
   1.527 +<ul class="simple">
   1.528 +<li>Using spec with <a class="reference internal" href="magicmock.html#mock.MagicMock" title="mock.MagicMock"><tt class="xref py py-class docutils literal"><span class="pre">MagicMock</span></tt></a> only pre-creates magic methods in the spec</li>
   1.529 +<li>Setting a magic method on a mock with a <tt class="docutils literal"><span class="pre">spec</span></tt> can only be done if the
   1.530 +spec has that method</li>
   1.531 +<li>Mocks can now be named (<cite>name</cite> argument to constructor) and the name is used
   1.532 +in the repr</li>
   1.533 +<li><cite>mocksignature</cite> can now be used with classes (signature based on <cite>__init__</cite>)
   1.534 +and callable objects (signature based on <cite>__call__</cite>)</li>
   1.535 +<li>Mocks created with a spec can now pass <cite>isinstance</cite> tests (<cite>__class__</cite>
   1.536 +returns the type of the spec)</li>
   1.537 +<li>Default numeric value for MagicMock is 1 rather than zero (because the
   1.538 +MagicMock bool defaults to True and 0 is False)</li>
   1.539 +<li>Improved failure message for <a class="reference internal" href="mock.html#mock.Mock.assert_called_with" title="mock.Mock.assert_called_with"><tt class="xref py py-meth docutils literal"><span class="pre">assert_called_with()</span></tt></a> when the mock
   1.540 +has not been called at all</li>
   1.541 +<li>Adding the following to the set of supported magic methods:<ul>
   1.542 +<li><tt class="docutils literal"><span class="pre">__getformat__</span></tt> and <tt class="docutils literal"><span class="pre">__setformat__</span></tt></li>
   1.543 +<li>pickle methods</li>
   1.544 +<li><tt class="docutils literal"><span class="pre">__trunc__</span></tt>, <tt class="docutils literal"><span class="pre">__ceil__</span></tt> and <tt class="docutils literal"><span class="pre">__floor__</span></tt></li>
   1.545 +<li><tt class="docutils literal"><span class="pre">__sizeof__</span></tt></li>
   1.546 +</ul>
   1.547 +</li>
   1.548 +<li>Added &#8216;build_sphinx&#8217; command to setup.py (requires setuptools or distribute)
   1.549 +Thanks to Florian Bauer</li>
   1.550 +<li>with statement tests now skipped on Python 2.4</li>
   1.551 +<li>Tests require unittest2 to run on Python 2.7</li>
   1.552 +<li>Improved several docstrings and documentation</li>
   1.553 +</ul>
   1.554 +</div>
   1.555 +<div class="section" id="version-0-7-0-beta-2">
   1.556 +<h2>2010/06/23 Version 0.7.0 beta 2<a class="headerlink" href="#version-0-7-0-beta-2" title="Permalink to this headline">¶</a></h2>
   1.557 +<ul class="simple">
   1.558 +<li><a class="reference internal" href="patch.html#mock.patch.dict" title="mock.patch.dict"><tt class="xref py py-func docutils literal"><span class="pre">patch.dict()</span></tt></a> works as a context manager as well as a decorator</li>
   1.559 +<li><tt class="docutils literal"><span class="pre">patch.dict</span></tt> takes a string to specify dictionary as well as a dictionary
   1.560 +object. If a string is supplied the name specified is imported</li>
   1.561 +<li>BUGFIX: <tt class="docutils literal"><span class="pre">patch.dict</span></tt> restores dictionary even when an exception is raised</li>
   1.562 +</ul>
   1.563 +</div>
   1.564 +<div class="section" id="version-0-7-0-beta-1">
   1.565 +<h2>2010/06/22 Version 0.7.0 beta 1<a class="headerlink" href="#version-0-7-0-beta-1" title="Permalink to this headline">¶</a></h2>
   1.566 +<ul class="simple">
   1.567 +<li>Addition of <tt class="xref py py-func docutils literal"><span class="pre">mocksignature()</span></tt></li>
   1.568 +<li>Ability to mock magic methods</li>
   1.569 +<li>Ability to use <tt class="docutils literal"><span class="pre">patch</span></tt> and <tt class="docutils literal"><span class="pre">patch.object</span></tt> as class decorators</li>
   1.570 +<li>Renamed <tt class="docutils literal"><span class="pre">patch_object</span></tt> to <a class="reference internal" href="patch.html#mock.patch.object" title="mock.patch.object"><tt class="xref py py-func docutils literal"><span class="pre">patch.object()</span></tt></a> (<tt class="docutils literal"><span class="pre">patch_object</span></tt> is
   1.571 +deprecated)</li>
   1.572 +<li>Addition of <a class="reference internal" href="magicmock.html#mock.MagicMock" title="mock.MagicMock"><tt class="xref py py-class docutils literal"><span class="pre">MagicMock</span></tt></a> class with all magic methods pre-created for you</li>
   1.573 +<li>Python 3 compatibility (tested with 3.2 but should work with 3.0 &amp; 3.1 as
   1.574 +well)</li>
   1.575 +<li>Addition of <a class="reference internal" href="patch.html#mock.patch.dict" title="mock.patch.dict"><tt class="xref py py-func docutils literal"><span class="pre">patch.dict()</span></tt></a> for changing dictionaries during a test</li>
   1.576 +<li>Addition of <tt class="docutils literal"><span class="pre">mocksignature</span></tt> argument to <tt class="docutils literal"><span class="pre">patch</span></tt> and <tt class="docutils literal"><span class="pre">patch.object</span></tt></li>
   1.577 +<li><tt class="docutils literal"><span class="pre">help(mock)</span></tt> works now (on the module). Can no longer use <tt class="docutils literal"><span class="pre">__bases__</span></tt>
   1.578 +as a valid sentinel name (thanks to Stephen Emslie for reporting and
   1.579 +diagnosing this)</li>
   1.580 +<li>Addition of soft comparisons: <cite>call_args</cite>, <cite>call_args_list</cite> and <cite>method_calls</cite>
   1.581 +now return tuple-like objects which compare equal even when empty args
   1.582 +or kwargs are skipped</li>
   1.583 +<li>Added docstrings.</li>
   1.584 +<li>BUGFIX: <tt class="docutils literal"><span class="pre">side_effect</span></tt> now works with <tt class="docutils literal"><span class="pre">BaseException</span></tt> exceptions like
   1.585 +<tt class="docutils literal"><span class="pre">KeyboardInterrupt</span></tt></li>
   1.586 +<li>BUGFIX: patching the same object twice now restores the patches correctly</li>
   1.587 +<li>The tests now require <a class="reference external" href="http://pypi.python.org/pypi/unittest2">unittest2</a>
   1.588 +to run</li>
   1.589 +<li><a class="reference external" href="http://konryd.blogspot.com/">Konrad Delong</a> added as co-maintainer</li>
   1.590 +</ul>
   1.591 +</div>
   1.592 +<div class="section" id="version-0-6-0">
   1.593 +<h2>2009/08/22 Version 0.6.0<a class="headerlink" href="#version-0-6-0" title="Permalink to this headline">¶</a></h2>
   1.594 +<ul class="simple">
   1.595 +<li>New test layout compatible with test discovery</li>
   1.596 +<li>Descriptors (static methods / class methods etc) can now be patched and
   1.597 +restored correctly</li>
   1.598 +<li>Mocks can raise exceptions when called by setting <tt class="docutils literal"><span class="pre">side_effect</span></tt> to an
   1.599 +exception class or instance</li>
   1.600 +<li>Mocks that wrap objects will not pass on calls to the underlying object if
   1.601 +an explicit return_value is set</li>
   1.602 +</ul>
   1.603 +</div>
   1.604 +<div class="section" id="version-0-5-0">
   1.605 +<h2>2009/04/17 Version 0.5.0<a class="headerlink" href="#version-0-5-0" title="Permalink to this headline">¶</a></h2>
   1.606 +<ul class="simple">
   1.607 +<li>Made DEFAULT part of the public api.</li>
   1.608 +<li>Documentation built with Sphinx.</li>
   1.609 +<li><tt class="docutils literal"><span class="pre">side_effect</span></tt> is now called with the same arguments as the mock is called with and
   1.610 +if returns a non-DEFAULT value that is automatically set as the <tt class="docutils literal"><span class="pre">mock.return_value</span></tt>.</li>
   1.611 +<li><tt class="docutils literal"><span class="pre">wraps</span></tt> keyword argument used for wrapping objects (and passing calls through to the wrapped object).</li>
   1.612 +<li><tt class="docutils literal"><span class="pre">Mock.reset</span></tt> renamed to <tt class="docutils literal"><span class="pre">Mock.reset_mock</span></tt>, as reset is a common API name.</li>
   1.613 +<li><tt class="docutils literal"><span class="pre">patch</span></tt> / <tt class="docutils literal"><span class="pre">patch_object</span></tt> are now context managers and can be used with <tt class="docutils literal"><span class="pre">with</span></tt>.</li>
   1.614 +<li>A new &#8216;create&#8217; keyword argument to patch and patch_object that allows them to patch
   1.615 +(and unpatch) attributes that don&#8217;t exist. (Potentially unsafe to use - it can allow
   1.616 +you to have tests that pass when they are testing an API that doesn&#8217;t exist - use at
   1.617 +your own risk!)</li>
   1.618 +<li>The methods keyword argument to Mock has been removed and merged with spec. The spec
   1.619 +argument can now be a list of methods or an object to take the spec from.</li>
   1.620 +<li>Nested patches may now be applied in a different order (created mocks passed
   1.621 +in the opposite order). This is actually a bugfix.</li>
   1.622 +<li>patch and patch_object now take a spec keyword argument. If spec is
   1.623 +passed in as &#8216;True&#8217; then the Mock created will take the object it is replacing
   1.624 +as its spec object. If the object being replaced is a class, then the return
   1.625 +value for the mock will also use the class as a spec.</li>
   1.626 +<li>A Mock created without a spec will not attempt to mock any magic methods / attributes
   1.627 +(they will raise an <tt class="docutils literal"><span class="pre">AttributeError</span></tt> instead).</li>
   1.628 +</ul>
   1.629 +</div>
   1.630 +<div class="section" id="version-0-4-0">
   1.631 +<h2>2008/10/12 Version 0.4.0<a class="headerlink" href="#version-0-4-0" title="Permalink to this headline">¶</a></h2>
   1.632 +<ul>
   1.633 +<li><p class="first">Default return value is now a new mock rather than None</p>
   1.634 +</li>
   1.635 +<li><p class="first">return_value added as a keyword argument to the constructor</p>
   1.636 +</li>
   1.637 +<li><p class="first">New method &#8216;assert_called_with&#8217;</p>
   1.638 +</li>
   1.639 +<li><p class="first">Added &#8216;side_effect&#8217; attribute / keyword argument called when mock is called</p>
   1.640 +</li>
   1.641 +<li><p class="first">patch decorator split into two decorators:</p>
   1.642 +<blockquote>
   1.643 +<div><ul class="simple">
   1.644 +<li><tt class="docutils literal"><span class="pre">patch_object</span></tt> which takes an object and an attribute name to patch
   1.645 +(plus optionally a value to patch with which defaults to a mock object)</li>
   1.646 +<li><tt class="docutils literal"><span class="pre">patch</span></tt> which takes a string specifying a target to patch; in the form
   1.647 +&#8216;package.module.Class.attribute&#8217;. (plus optionally a value to
   1.648 +patch with which defaults to a mock object)</li>
   1.649 +</ul>
   1.650 +</div></blockquote>
   1.651 +</li>
   1.652 +<li><p class="first">Can now patch objects with <tt class="docutils literal"><span class="pre">None</span></tt></p>
   1.653 +</li>
   1.654 +<li><p class="first">Change to patch for nose compatibility with error reporting in wrapped functions</p>
   1.655 +</li>
   1.656 +<li><p class="first">Reset no longer clears children / return value etc - it just resets
   1.657 +call count and call args. It also calls reset on all children (and
   1.658 +the return value if it is a mock).</p>
   1.659 +</li>
   1.660 +</ul>
   1.661 +<p>Thanks to Konrad Delong, Kevin Dangoor and others for patches and suggestions.</p>
   1.662 +</div>
   1.663 +<div class="section" id="version-0-3-1">
   1.664 +<h2>2007/12/03  Version 0.3.1<a class="headerlink" href="#version-0-3-1" title="Permalink to this headline">¶</a></h2>
   1.665 +<p><tt class="docutils literal"><span class="pre">patch</span></tt> maintains the name of decorated functions for compatibility with nose
   1.666 +test autodiscovery.</p>
   1.667 +<p>Tests decorated with <tt class="docutils literal"><span class="pre">patch</span></tt> that use the two argument form (implicit mock
   1.668 +creation) will receive the mock(s) passed in as extra arguments.</p>
   1.669 +<p>Thanks to Kevin Dangoor for these changes.</p>
   1.670 +</div>
   1.671 +<div class="section" id="version-0-3-0">
   1.672 +<h2>2007/11/30  Version 0.3.0<a class="headerlink" href="#version-0-3-0" title="Permalink to this headline">¶</a></h2>
   1.673 +<p>Removed <tt class="docutils literal"><span class="pre">patch_module</span></tt>. <tt class="docutils literal"><span class="pre">patch</span></tt> can now take a string as the first
   1.674 +argument for patching modules.</p>
   1.675 +<p>The third argument to <tt class="docutils literal"><span class="pre">patch</span></tt> is optional - a mock will be created by
   1.676 +default if it is not passed in.</p>
   1.677 +</div>
   1.678 +<div class="section" id="version-0-2-1">
   1.679 +<h2>2007/11/21  Version 0.2.1<a class="headerlink" href="#version-0-2-1" title="Permalink to this headline">¶</a></h2>
   1.680 +<p>Bug fix, allows reuse of functions decorated with <tt class="docutils literal"><span class="pre">patch</span></tt> and <tt class="docutils literal"><span class="pre">patch_module</span></tt>.</p>
   1.681 +</div>
   1.682 +<div class="section" id="version-0-2-0">
   1.683 +<h2>2007/11/20  Version 0.2.0<a class="headerlink" href="#version-0-2-0" title="Permalink to this headline">¶</a></h2>
   1.684 +<p>Added <tt class="docutils literal"><span class="pre">spec</span></tt> keyword argument for creating <tt class="docutils literal"><span class="pre">Mock</span></tt> objects from a
   1.685 +specification object.</p>
   1.686 +<p>Added <tt class="docutils literal"><span class="pre">patch</span></tt> and <tt class="docutils literal"><span class="pre">patch_module</span></tt> monkey patching decorators.</p>
   1.687 +<p>Added <tt class="docutils literal"><span class="pre">sentinel</span></tt> for convenient access to unique objects.</p>
   1.688 +<p>Distribution includes unit tests.</p>
   1.689 +</div>
   1.690 +<div class="section" id="version-0-1-0">
   1.691 +<h2>2007/11/19  Version 0.1.0<a class="headerlink" href="#version-0-1-0" title="Permalink to this headline">¶</a></h2>
   1.692 +<p>Initial release.</p>
   1.693 +</div>
   1.694 +</div>
   1.695 +<div class="section" id="todo-and-limitations">
   1.696 +<h1>TODO and Limitations<a class="headerlink" href="#todo-and-limitations" title="Permalink to this headline">¶</a></h1>
   1.697 +<p>Contributions, bug reports and comments welcomed!</p>
   1.698 +<p>Feature requests and bug reports are handled on the issue tracker:</p>
   1.699 +<blockquote>
   1.700 +<div><ul class="simple">
   1.701 +<li><a class="reference external" href="http://code.google.com/p/mock/issues/list">mock issue tracker</a></li>
   1.702 +</ul>
   1.703 +</div></blockquote>
   1.704 +<p><cite>wraps</cite> is not integrated with magic methods.</p>
   1.705 +<p><cite>patch</cite> could auto-do the patching in the constructor and unpatch in the
   1.706 +destructor. This would be useful in itself, but violates TOOWTDI and would be
   1.707 +unsafe for IronPython &amp; PyPy (non-deterministic calling of destructors).
   1.708 +Destructors aren&#8217;t called in CPython where there are cycles, but a weak
   1.709 +reference with a callback can be used to get round this.</p>
   1.710 +<p><cite>Mock</cite> has several attributes. This makes it unsuitable for mocking objects
   1.711 +that use these attribute names. A way round this would be to provide methods
   1.712 +that <em>hide</em> these attributes when needed. In 0.8 many, but not all, of these
   1.713 +attributes are renamed to gain a <cite>_mock</cite> prefix, making it less likely that
   1.714 +they will clash. Any outstanding attributes that haven&#8217;t been modified with
   1.715 +the prefix should be changed.</p>
   1.716 +<p>If a patch is started using <cite>patch.start</cite> and then not stopped correctly then
   1.717 +the unpatching is not done. Using weak references it would be possible to
   1.718 +detect and fix this when the patch object itself is garbage collected. This
   1.719 +would be tricky to get right though.</p>
   1.720 +<p>When a <cite>Mock</cite> is created by <cite>patch</cite>, arbitrary keywords can be used to set
   1.721 +attributes. If <cite>patch</cite> is created with a <cite>spec</cite>, and is replacing a class, then
   1.722 +a <cite>return_value</cite> mock is created. The keyword arguments are not applied to the
   1.723 +child mock, but could be.</p>
   1.724 +<p>When mocking a class with <cite>patch</cite>, passing in <cite>spec=True</cite> or <cite>autospec=True</cite>,
   1.725 +the mock class has an instance created from the same spec. Should this be the
   1.726 +default behaviour for mocks anyway (mock return values inheriting the spec
   1.727 +from their parent), or should it be controlled by an additional keyword
   1.728 +argument (<cite>inherit</cite>) to the Mock constructor? <cite>create_autospec</cite> does this, so
   1.729 +an additional keyword argument to Mock is probably unnecessary.</p>
   1.730 +<p>The <cite>mocksignature</cite> argument to <cite>patch</cite> with a non <cite>Mock</cite> passed into
   1.731 +<cite>new_callable</cite> will <em>probably</em> cause an error. Should it just be invalid?</p>
   1.732 +<p>Note that <cite>NonCallableMock</cite> and <cite>NonCallableMagicMock</cite> still have the unused
   1.733 +(and unusable) attributes: <cite>return_value</cite>, <cite>side_effect</cite>, <cite>call_count</cite>,
   1.734 +<cite>call_args</cite> and <cite>call_args_list</cite>. These could be removed or raise errors on
   1.735 +getting / setting. They also have the <cite>assert_called_with</cite> and
   1.736 +<cite>assert_called_once_with</cite> methods. Removing these would be pointless as
   1.737 +fetching them would create a mock (attribute) that could be called without
   1.738 +error.</p>
   1.739 +<p>Some outstanding technical debt. The way autospeccing mocks function
   1.740 +signatures was copied and modified from <cite>mocksignature</cite>. This could all be
   1.741 +refactored into one set of functions instead of two. The way we tell if
   1.742 +patchers are started and if a patcher is being used for a <cite>patch.multiple</cite>
   1.743 +call are both horrible. There are now a host of helper functions that should
   1.744 +be rationalised. (Probably time to split mock into a package instead of a
   1.745 +module.)</p>
   1.746 +<p>Passing arbitrary keyword arguments to <cite>create_autospec</cite>, or <cite>patch</cite> with
   1.747 +<cite>autospec</cite>, when mocking a <em>function</em> works fine. However, the arbitrary
   1.748 +attributes are set on the created mock - but <cite>create_autospec</cite> returns a
   1.749 +real function (which doesn&#8217;t have those attributes). However, what is the use
   1.750 +case for using autospec to create functions with attributes that don&#8217;t exist
   1.751 +on the original?</p>
   1.752 +<p><cite>mocksignature</cite>, plus the <cite>call_args_list</cite> and <cite>method_calls</cite> attributes of
   1.753 +<cite>Mock</cite> could all be deprecated.</p>
   1.754 +</div>
   1.755 +
   1.756 +
   1.757 +          </div>
   1.758 +        </div>
   1.759 +      </div>
   1.760 +      <div class="sphinxsidebar">
   1.761 +        <div class="sphinxsidebarwrapper">
   1.762 +  <h3><a href="index.html">Table Of Contents</a></h3>
   1.763 +  <ul>
   1.764 +<li><a class="reference internal" href="#">CHANGELOG</a><ul>
   1.765 +<li><a class="reference internal" href="#version-1-0-0">2012/10/07 Version 1.0.0</a></li>
   1.766 +<li><a class="reference internal" href="#version-1-0-0-beta-1">2012/07/13 Version 1.0.0 beta 1</a></li>
   1.767 +<li><a class="reference internal" href="#version-1-0-0-alpha-2">2012/05/04 Version 1.0.0 alpha 2</a></li>
   1.768 +<li><a class="reference internal" href="#version-1-0-0-alpha-1">2012/03/25 Version 1.0.0 alpha 1</a></li>
   1.769 +<li><a class="reference internal" href="#version-0-8-0">2012/02/13 Version 0.8.0</a></li>
   1.770 +<li><a class="reference internal" href="#version-0-8-0-release-candidate-2">2012/01/10 Version 0.8.0 release candidate 2</a></li>
   1.771 +<li><a class="reference internal" href="#version-0-8-0-release-candidate-1">2011/12/29 Version 0.8.0 release candidate 1</a></li>
   1.772 +<li><a class="reference internal" href="#version-0-8-0-beta-4">2011/10/09 Version 0.8.0 beta 4</a></li>
   1.773 +<li><a class="reference internal" href="#version-0-8-0-beta-3">2011/08/15 Version 0.8.0 beta 3</a></li>
   1.774 +<li><a class="reference internal" href="#version-0-8-0-beta-2">2011/08/05 Version 0.8.0 beta 2</a></li>
   1.775 +<li><a class="reference internal" href="#version-0-8-0-beta-1">2011/07/25 Version 0.8.0 beta 1</a></li>
   1.776 +<li><a class="reference internal" href="#version-0-8-0-alpha-2">2011/07/16 Version 0.8.0 alpha 2</a></li>
   1.777 +<li><a class="reference internal" href="#version-0-8-0-alpha-1">2011/06/14 Version 0.8.0 alpha 1</a></li>
   1.778 +<li><a class="reference internal" href="#version-0-7-2">2011/05/30 Version 0.7.2</a></li>
   1.779 +<li><a class="reference internal" href="#version-0-7-1">2011/05/06 Version 0.7.1</a></li>
   1.780 +<li><a class="reference internal" href="#version-0-7-0">2011/03/05 Version 0.7.0</a></li>
   1.781 +<li><a class="reference internal" href="#version-0-7-0-rc-1">2011/02/16 Version 0.7.0 RC 1</a></li>
   1.782 +<li><a class="reference internal" href="#version-0-7-0-beta-4">2010/11/12 Version 0.7.0 beta 4</a></li>
   1.783 +<li><a class="reference internal" href="#version-0-7-0-beta-3">2010/09/18 Version 0.7.0 beta 3</a></li>
   1.784 +<li><a class="reference internal" href="#version-0-7-0-beta-2">2010/06/23 Version 0.7.0 beta 2</a></li>
   1.785 +<li><a class="reference internal" href="#version-0-7-0-beta-1">2010/06/22 Version 0.7.0 beta 1</a></li>
   1.786 +<li><a class="reference internal" href="#version-0-6-0">2009/08/22 Version 0.6.0</a></li>
   1.787 +<li><a class="reference internal" href="#version-0-5-0">2009/04/17 Version 0.5.0</a></li>
   1.788 +<li><a class="reference internal" href="#version-0-4-0">2008/10/12 Version 0.4.0</a></li>
   1.789 +<li><a class="reference internal" href="#version-0-3-1">2007/12/03  Version 0.3.1</a></li>
   1.790 +<li><a class="reference internal" href="#version-0-3-0">2007/11/30  Version 0.3.0</a></li>
   1.791 +<li><a class="reference internal" href="#version-0-2-1">2007/11/21  Version 0.2.1</a></li>
   1.792 +<li><a class="reference internal" href="#version-0-2-0">2007/11/20  Version 0.2.0</a></li>
   1.793 +<li><a class="reference internal" href="#version-0-1-0">2007/11/19  Version 0.1.0</a></li>
   1.794 +</ul>
   1.795 +</li>
   1.796 +<li><a class="reference internal" href="#todo-and-limitations">TODO and Limitations</a></li>
   1.797 +</ul>
   1.798 +
   1.799 +  <h4>Previous topic</h4>
   1.800 +  <p class="topless"><a href="compare.html"
   1.801 +                        title="previous chapter">Mock Library Comparison</a></p>
   1.802 +  <h3>This Page</h3>
   1.803 +  <ul class="this-page-menu">
   1.804 +    <li><a href="_sources/changelog.txt"
   1.805 +           rel="nofollow">Show Source</a></li>
   1.806 +  </ul>
   1.807 +<div id="searchbox" style="display: none">
   1.808 +  <h3>Quick search</h3>
   1.809 +    <form class="search" action="search.html" method="get">
   1.810 +      <input type="text" name="q" />
   1.811 +      <input type="submit" value="Go" />
   1.812 +      <input type="hidden" name="check_keywords" value="yes" />
   1.813 +      <input type="hidden" name="area" value="default" />
   1.814 +    </form>
   1.815 +    <p class="searchtip" style="font-size: 90%">
   1.816 +    Enter search terms or a module, class or function name.
   1.817 +    </p>
   1.818 +</div>
   1.819 +<script type="text/javascript">$('#searchbox').show(0);</script>
   1.820 +        </div>
   1.821 +      </div>
   1.822 +      <div class="clearer"></div>
   1.823 +    </div>
   1.824 +    <div class="related">
   1.825 +      <h3>Navigation</h3>
   1.826 +      <ul>
   1.827 +        <li class="right" style="margin-right: 10px">
   1.828 +          <a href="genindex.html" title="General Index"
   1.829 +             >index</a></li>
   1.830 +        <li class="right" >
   1.831 +          <a href="compare.html" title="Mock Library Comparison"
   1.832 +             >previous</a> |</li>
   1.833 +        <li><a href="index.html">Mock 1.0.0 documentation</a> &raquo;</li> 
   1.834 +      </ul>
   1.835 +    </div>
   1.836 +    <div class="footer">
   1.837 +        &copy; Copyright 2007-2012, Michael Foord &amp; the mock team.
   1.838 +      Last updated on Oct 07, 2012.
   1.839 +      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
   1.840 +    </div>
   1.841 +  </body>
   1.842 +</html>
   1.843 \ No newline at end of file

mercurial