diff options
author | Michael Foord <michael@python.org> | 2011-05-14 12:12:52 +0200 |
---|---|---|
committer | Michael Foord <michael@python.org> | 2011-05-14 12:12:52 +0200 |
commit | 23a6a82fd8497c60651dbf12f68e31f574677091 (patch) | |
tree | 805fc57b3c027291d188fc98e6788cd66dd539d2 | |
parent | 6d67b025a2aaed0f4482a04273a42ca0884b28f4 (diff) | |
download | mock-23a6a82fd8497c60651dbf12f68e31f574677091.tar.gz |
Testing call
-rw-r--r-- | README.txt | 4 | ||||
-rw-r--r-- | docs/index.txt | 10 | ||||
-rw-r--r-- | tests/testhelpers.py | 37 |
3 files changed, 26 insertions, 25 deletions
@@ -9,8 +9,8 @@ mock is tested on Python versions 2.4-2.7 and Python 3. The mock module also provides utility functions / objects to assist with testing, particularly monkey patching. -* `PDF documentation for 0.7.1 - <http://www.voidspace.org.uk/downloads/mock-0.7.1.pdf>`_ +* `PDF documentation for 0.8.0 alpha 1 + <http://www.voidspace.org.uk/downloads/mock-0.8.0a1.pdf>`_ * `mock on google code (repository and issue tracker) <http://code.google.com/p/mock/>`_ * `mock documentation diff --git a/docs/index.txt b/docs/index.txt index 7169f84..291a20f 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -7,10 +7,10 @@ :Author: `Michael Foord <http://www.voidspace.org.uk/python/weblog/index.shtml>`_ :Co-maintainer: `Konrad Delong <http://konryd.blogspot.com/>`_ :Version: |release| -:Date: 2011/03/05 +:Date: 2011/XX/XX :Homepage: `Mock Homepage`_ :Download: `Mock on PyPI`_ -:Documentation: `PDF Documentation <http://www.voidspace.org.uk/downloads/mock-0.7.1.pdf>`_ +:Documentation: `PDF Documentation <http://www.voidspace.org.uk/downloads/mock-0.8.0a1.pdf>`_ :License: `BSD License`_ :Support: `Mailing list (testing-in-python@lists.idyll.org) <http://lists.idyll.org/listinfo/testing-in-python>`_ :Issue tracker: `Google code project <http://code.google.com/p/mock/issues/list>`_ @@ -44,7 +44,6 @@ mocking frameworks. mock is tested on Python versions 2.4-2.7 and Python 3. - .. testsetup:: import sys @@ -333,7 +332,10 @@ Older Versions Documentation for older versions of mock: -* `mock 0.6.0 <http://www.voidspace.org.uk/python/mock/0.6.0/>`_ +# XXXX + +* `mock 0.7 <http://www.voidspace.org.uk/python/mock/0.7/>`_ +* `mock 0.6 <http://www.voidspace.org.uk/python/mock/0.6.0/>`_ Terminology diff --git a/tests/testhelpers.py b/tests/testhelpers.py index 155f13d..134b0da 100644 --- a/tests/testhelpers.py +++ b/tests/testhelpers.py @@ -28,25 +28,6 @@ class AnyTest(unittest2.TestCase): class CallTest(unittest2.TestCase): """ - >>> mock = Mock(return_value=None) - >>> mock(1, 2, 3) - >>> mock(a=3, b=6) - >>> mock.call_args_list == [call(1, 2, 3), call(a=3, b=6)] - True - - >>> mock = Mock() - >>> mock.foo(1, 2 ,3) - <mock.Mock object at 0x...> - >>> mock.bar.baz(a=3, b=6) - <mock.Mock object at 0x...> - >>> mock.method_calls == [call.foo(1, 2, 3), call.bar.baz(a=3, b=6)] - True - -And for good measure, the first example (tracking order of calls between -mocks) using the new `call` object for assertions: - -.. doctest:: - >>> manager = Mock() >>> mock_foo = manager.foo @@ -71,3 +52,21 @@ mocks) using the new `call` object for assertions: self.assertEqual(call(), ((), {})) self.assertEqual(call('foo', 'bar', one=3, two=4), (('foo', 'bar'), {'one': 3, 'two': 4})) + + mock = Mock() + mock(1, 2, 3) + mock(a=3, b=6) + self.assertEqual(mock.call_args_list, + [call(1, 2, 3), call(a=3, b=6)]) + + def test_attribute_call(self): + self.assertEqual(call.foo(1), ('foo', (1,), {})) + self.assertEqual(call.bar.baz(fish='eggs'), + ('bar.baz', (), {'fish': 'eggs'})) + + mock = Mock() + mock.foo(1, 2 ,3) + mock.bar.baz(a=3, b=6) + self.assertEqual(mock.method_calls, + [call.foo(1, 2, 3), call.bar.baz(a=3, b=6)]) + |