Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-python-testing-cabal-mock
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-python-testing-cabal-mock
Commits
c9771edb
Commit
c9771edb
authored
14 years ago
by
Michael Foord
Browse files
Options
Downloads
Patches
Plain Diff
Docs and changelog updates
parent
2952dc51
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/changelog.txt
+54
-1
54 additions, 1 deletion
docs/changelog.txt
docs/patch.txt
+5
-2
5 additions, 2 deletions
docs/patch.txt
with
59 additions
and
3 deletions
docs/changelog.txt
+
54
−
1
View file @
c9771edb
...
...
@@ -44,6 +44,59 @@ itself is garbage collected. This is tricky to get right though.
CHANGELOG
=========
2010/XX/XX Version 0.7.0
------------------------
Changes since beta 4:
Full set of changes since 0.6.0:
* Ability to mock magic methods with `Mock` and addition of `MagicMock`
with pre-created magic methods
* Addition of `mocksignature`
* Addition of `mocksignature` argument to `patch` and `patch.object`
* Addition of `patch.dict` for changing dictionaries during a test
* Ability to use `patch`, `patch.object` and `patch.dict` as class decorators
* Renamed ``patch_object`` to `patch.object` (``patch_object`` is
deprecated)
* Addition of soft comparisons: `call_args`, `call_args_list` and `method_calls`
now return tuple-like objects which compare equal even when empty args
or kwargs are skipped
* patchers (`patch`, `patch.object` and `patch.dict`) have start and stop
methods
* Addition of `assert_called_once_with` method
* Mocks can now be named (`name` argument to constructor) and the name is used
in the repr
* repr of a mock with a spec includes the class name of the spec
* `assert_called_with` works with `python -OO`
* New `spec_set` keyword argument to `Mock` and `patch`. If this is set,
attempting to *set* an attribute on a mock not on the spec will raise an
`AttributeError`
* Mocks created with a spec can now pass `isinstance` tests (`__class__`
returns the type of the spec)
* Improved failure message for `Mock.assert_called_with` when the mock
has not been called at all
* BUGFIX: mocks are now copyable (thanks to Ned Batchelder for reporting and
diagnosing this)
* BUGFIX: `spec=True` works with old style classes
* BUGFIX: ``help(mock)`` works now (on the module). Can no longer use ``__bases__``
as a valid sentinel name (thanks to Stephen Emslie for reporting and
diagnosing this)
* BUGFIX: ``side_effect`` now works with ``BaseException`` exceptions like
``KeyboardInterrupt``
* BUGFIX: patching the same object twice now restores the patches correctly
* Python 3 compatibility (tested with 3.2 but should work with 3.0 & 3.1 as
well)
* with statement tests now skipped on Python 2.4
* Tests require unittest2 to run
* Improved several docstrings and documentation
* Added 'build_sphinx' command to setup.py (requires setuptools or distribute)
Thanks to Florian Bauer
* Switched from subversion to mercurial for source code control
* `Konrad Delong <http://konryd.blogspot.com/>`_ added as co-maintainer
2010/11/12 Version 0.7.0 beta 4
-------------------------------
...
...
@@ -122,7 +175,7 @@ CHANGELOG
as a valid sentinel name (thanks to Stephen Emslie for reporting and
diagnosing this)
* Addition of soft comparisons: `call_args`, `call_args_list` and `method_calls`
return
now
tuple-like objects which compare equal even when empty args
now
return tuple-like objects which compare equal even when empty args
or kwargs are skipped
* Added docstrings.
* BUGFIX: ``side_effect`` now works with ``BaseException`` exceptions like
...
...
This diff is collapsed.
Click to expand it.
docs/patch.txt
+
5
−
2
View file @
c9771edb
...
...
@@ -125,14 +125,17 @@ decorators.
You can stack up multiple patch decorators using this pattern::
@patch('module.ClassName1')
@patch('module.ClassName2')
def testMethod(self, MockClass2, MockClass1):
@patch('module.ClassName1')
def testMethod(self, MockClass1, MockClass2):
ClassName1()
ClassName2()
self.assertEqual(MockClass1.called, "ClassName1 not patched")
self.assertEqual(MockClass2.called, "ClassName2 not patched")
Note that the decorators are applied from the bottom upwards. This is the
standard way that Python applies decorators. The order of the created mocks
passed into your test function matches this order.
Like all context-managers patches can be nested using contextlib's nested
function; *every* patching will appear in the tuple after "as"::
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment