[Python-modules-commits] [python-fudge] 09/15: Import python-fudge_1.1.0.orig.tar.gz

Jan Dittberner jandd at moszumanska.debian.org
Wed Dec 30 15:20:38 UTC 2015


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

jandd pushed a commit to branch master
in repository python-fudge.

commit 7d6f9fe539e3e84ab582a2e10b3265b0dcb5aa0b
Author: Jan Dittberner <jandd at debian.org>
Date:   Wed Dec 30 16:01:12 2015 +0100

    Import python-fudge_1.1.0.orig.tar.gz
---
 ._MANIFEST.in                            | Bin 185 -> 0 bytes
 ._README.txt                             | Bin 187 -> 0 bytes
 ._run_tests.sh                           | Bin 186 -> 0 bytes
 ._setup.py                               | Bin 187 -> 0 bytes
 PKG-INFO                                 |   6 +-
 README.txt                               |  24 --
 docs/._Makefile                          | Bin 186 -> 0 bytes
 docs/._index.rst                         | Bin 187 -> 0 bytes
 docs/._migrating-0.9-to-1.0.rst          | Bin 188 -> 0 bytes
 docs/._using-fudge.rst                   | Bin 188 -> 0 bytes
 docs/_doctest_support/auth/.___init__.py | Bin 186 -> 0 bytes
 docs/api/._fudge.rst                     | Bin 186 -> 0 bytes
 docs/api/fudge.inspector.rst             |   7 +-
 docs/index.rst                           |  19 +-
 docs/using-fudge.rst                     | 112 ++++--
 fudge.egg-info/PKG-INFO                  |   6 +-
 fudge.egg-info/SOURCES.txt               |   1 -
 fudge/.___init__.py                      | Bin 188 -> 0 bytes
 fudge/._inspector.py                     | Bin 186 -> 0 bytes
 fudge/._patcher.py                       | Bin 243 -> 0 bytes
 fudge/__init__.py                        | 664 ++++++++++++++++++-------------
 fudge/inspector.py                       | 462 +++++++++++++++------
 fudge/tests/.___init__.py                | Bin 184 -> 0 bytes
 fudge/tests/._test_fudge.py              | Bin 188 -> 0 bytes
 fudge/tests/._test_import_all.py         | Bin 186 -> 0 bytes
 fudge/tests/._test_inspector.py          | Bin 187 -> 0 bytes
 fudge/tests/._test_patcher.py            | Bin 242 -> 0 bytes
 fudge/tests/._test_registry.py           | Bin 187 -> 0 bytes
 fudge/tests/support/.___init__.py        | Bin 184 -> 0 bytes
 fudge/tests/support/.__for_patch.py      | Bin 185 -> 0 bytes
 fudge/tests/test_fudge.py                | 437 ++++++++++----------
 fudge/tests/test_inspector.py            | 157 +++++---
 setup.py                                 |   2 +-
 33 files changed, 1147 insertions(+), 750 deletions(-)

diff --git a/._MANIFEST.in b/._MANIFEST.in
deleted file mode 100644
index 3ade54a..0000000
Binary files a/._MANIFEST.in and /dev/null differ
diff --git a/._README.txt b/._README.txt
deleted file mode 100644
index 69a1e98..0000000
Binary files a/._README.txt and /dev/null differ
diff --git a/._run_tests.sh b/._run_tests.sh
deleted file mode 100755
index 9b46ca3..0000000
Binary files a/._run_tests.sh and /dev/null differ
diff --git a/._setup.py b/._setup.py
deleted file mode 100644
index 846e248..0000000
Binary files a/._setup.py and /dev/null differ
diff --git a/PKG-INFO b/PKG-INFO
index 7a1ef9e..d57dbae 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,8 +1,8 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
 Name: fudge
-Version: 1.0.3
+Version: 1.1.0
 Summary: Replace real objects with fakes (mocks, stubs, etc) while testing.
-Home-page: http://farmdev.com/projects/fudge/
+Home-page: https://github.com/fudge-py/fudge
 Author: Kumar McMillan
 Author-email: kumar.mcmillan at gmail.com
 License: The MIT License
diff --git a/README.txt b/README.txt
deleted file mode 100644
index 0c64d45..0000000
--- a/README.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-
-Fudge is a module for replacing real objects with fakes (mocks, stubs, etc) while testing.
-
-Documentation is available at http://farmdev.com/projects/fudge/ or else, you can build it from source like this::
-    
-    $ easy_install Sphinx
-    $ cd docs
-    $ make html
-
-then open _build/html/index.html in your web browser.
-
-To run tests, you can use tox for all supported versions of Python.
-You can install it with pip::
-    
-    $ pip install tox
-
-Then execute::
-    
-    $ ./run_tests.sh
-
-Or simply::
-    
-    $ tox
-
diff --git a/docs/._Makefile b/docs/._Makefile
deleted file mode 100644
index 6a347c1..0000000
Binary files a/docs/._Makefile and /dev/null differ
diff --git a/docs/._index.rst b/docs/._index.rst
deleted file mode 100644
index 0ebe68b..0000000
Binary files a/docs/._index.rst and /dev/null differ
diff --git a/docs/._migrating-0.9-to-1.0.rst b/docs/._migrating-0.9-to-1.0.rst
deleted file mode 100644
index 91b25b3..0000000
Binary files a/docs/._migrating-0.9-to-1.0.rst and /dev/null differ
diff --git a/docs/._using-fudge.rst b/docs/._using-fudge.rst
deleted file mode 100644
index c523161..0000000
Binary files a/docs/._using-fudge.rst and /dev/null differ
diff --git a/docs/_doctest_support/auth/.___init__.py b/docs/_doctest_support/auth/.___init__.py
deleted file mode 100644
index 6e85ac7..0000000
Binary files a/docs/_doctest_support/auth/.___init__.py and /dev/null differ
diff --git a/docs/api/._fudge.rst b/docs/api/._fudge.rst
deleted file mode 100644
index cbf344f..0000000
Binary files a/docs/api/._fudge.rst and /dev/null differ
diff --git a/docs/api/fudge.inspector.rst b/docs/api/fudge.inspector.rst
index 7a2226b..69349cd 100644
--- a/docs/api/fudge.inspector.rst
+++ b/docs/api/fudge.inspector.rst
@@ -4,6 +4,9 @@ fudge.inspector
 ----------------
 
 .. automodule:: fudge.inspector
-   
+
 .. autoclass:: fudge.inspector.ValueInspector
-   :members:
\ No newline at end of file
+   :members:
+
+.. autoclass:: fudge.inspector.NotValueInspector
+   :members: __call__
diff --git a/docs/index.rst b/docs/index.rst
index b0118e7..9e7e995 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -37,9 +37,9 @@ This step will convert the Fudge source code using the 2to3 tool.
 Source
 ======
 
-The Fudge source can be downloaded as a tar.gz file from http://pypi.python.org/pypi/fudge  
+The Fudge source can be downloaded as a tar.gz file from http://pypi.python.org/pypi/fudge
 
-Using `Mercurial <http://www.selenic.com/mercurial/wiki/>`_ you can clone the source from http://bitbucket.org/kumar303/fudge/  
+Using `Git <https://git-scm.com/>`_ you can clone the source from https://github.com/fudge-py/fudge/
 
 Fudge is free and open for usage under the `MIT license`_.
 
@@ -69,18 +69,27 @@ API Reference
 Contributing
 ============
 
-Please submit `bugs and patches <http://bitbucket.org/kumar303/fudge/issues/>`_, preferably with tests.  All contributors will be acknowledged.  Thanks!
+Please submit `bugs and patches <https://github.com/fudge-py/fudge/issues>`_, preferably with tests.  All contributors will be acknowledged.  Thanks!
 
 Credits
 =======
 
-Fudge was created by `Kumar McMillan <http://farmdev.com/>`_ and contains contributions by Cristian Esquivias, Michael Williamson, and Luis Fagundes.
+Fudge was created by `Kumar McMillan <http://farmdev.com/>`_ and contains contributions by Cristian Esquivias, Michael Williamson, Luis Fagundes and Jeremy Satterfield.
 
 .. _fudge-changelog:
 
 Changelog
 =========
 
+- 1.1.0
+
+  - **Changed** `moved to github <https://github.com/fudge-py/fudge/>`_ and added maintainers
+  - **Changed** remove support for python 3.1 and 3.2 in tests in lieu of 3.4
+  - added :func:`fudge.Fake.has_property`
+  - added :class:`IsInstance`
+  - added :func:`without_args`
+  - Deprecation warnings are now real warnings.
+
 - 1.0.3
 
   - Added :func:`fudge.Fake.is_a_stub` :ref:`documented here <creating-a-stub>`
@@ -176,4 +185,4 @@ Changelog
   
 - 0.9.0
   
-  - first release
\ No newline at end of file
+  - first release
diff --git a/docs/using-fudge.rst b/docs/using-fudge.rst
index 652d702..7e0792d 100644
--- a/docs/using-fudge.rst
+++ b/docs/using-fudge.rst
@@ -20,10 +20,10 @@ When testing code that uses a web service you probably want a fast set of tests
     ...     )
     ...     api.UpdateStatus(msg)
     ...     print "Sent: %s" % msg
-    >>> 
+    >>>
 
 Since the `oauthtwitter`_ module is maintained independently, your code should work as long as it calls the right methods.
-    
+
 A Simple Test Case
 ==================
 
@@ -32,7 +32,7 @@ You can use Fudge to replace the OAuthApi class with a fake and **declare an exp
 .. _oauthtwitter: http://code.google.com/p/oauth-python-twitter/
 
 .. doctest::
-    
+
     >>> import fudge
     >>> @fudge.patch('oauthtwitter.OAuthApi')
     ... def test(FakeOAuthApi):
@@ -41,25 +41,25 @@ You can use Fudge to replace the OAuthApi class with a fake and **declare an exp
     ...                             '<oauth_token>', '<oauth_token_secret>')
     ...                  .returns_fake()
     ...                  .expects('UpdateStatus').with_arg_count(1))
-    ... 
+    ...
     ...     post_msg_to_twitter("hey there fellow testing freaks!")
-    >>> 
+    >>>
 
 Let's break this down:
 
 1. The :func:`patch <fudge.patch>` decorator will temporarily patch in a fake
    object for the duration of the test and expose it as an argument to
    the test.  This allows you to add expectations or stubs.
-2. The :class:`fake <fudge.Fake>` object you see here expects a call (class 
-   instantiation) with four arguments having specific string values.  The 
-   returned value is an object instance (a new fake) that expects you to call 
+2. The :class:`fake <fudge.Fake>` object you see here expects a call (class
+   instantiation) with four arguments having specific string values.  The
+   returned value is an object instance (a new fake) that expects you to call
    ``fake_oauth.UpdateStatus()`` with one argument.
 3. Finally, ``post_msg_to_twitter()`` is called.
 
 Let's run the test!
 
 .. doctest::
-  
+
   >>> test()
   Sent: hey there fellow testing freaks!
 
@@ -70,16 +70,16 @@ Fudge lets you declare expectations as loose or as tight as you want.  If you do
 Fake objects without patches (dependency injection)
 ===================================================
 
-If you don't need to patch anything, you can use the :func:`fudge.test` 
-decorator instead.  This will ensure an exception is raised in case any 
+If you don't need to patch anything, you can use the :func:`fudge.test`
+decorator instead.  This will ensure an exception is raised in case any
 expectations aren't met.  Here's an example:
 
 .. doctest::
-    
+
     >>> def send_msg(api):
     ...     if False: # a mistake
     ...         api.UpdateStatus('hello')
-    ... 
+    ...
     >>> @fudge.test
     ... def test_msg():
     ...     FakeOAuthApi = (fudge.Fake('OAuthApi')
@@ -87,7 +87,7 @@ expectations aren't met.  Here's an example:
     ...                          .expects('UpdateStatus'))
     ...     api = FakeOAuthApi()
     ...     send_msg(api)
-    ... 
+    ...
     >>> test_msg()
     Traceback (most recent call last):
     ...
@@ -95,20 +95,20 @@ expectations aren't met.  Here's an example:
 
 .. doctest::
     :hide:
-    
+
     >>> fudge.clear_expectations()
 
 Stubs Without Expectations
 ==========================
 
-If you want a fake object where the methods can be called but are not 
-expected to be called, the code is just the same but instead of 
-:meth:`Fake.expects() <fudge.Fake.expects>` you use :meth:`Fake.provides() <fudge.Fake.provides>`.  Here is an example of always returning True 
+If you want a fake object where the methods can be called but are not
+expected to be called, the code is just the same but instead of
+:meth:`Fake.expects() <fudge.Fake.expects>` you use :meth:`Fake.provides() <fudge.Fake.provides>`.  Here is an example of always returning True
 for the method is_logged_in():
 
 .. doctest::
     :hide:
-    
+
     >>> import fudge
 
 .. doctest::
@@ -120,13 +120,13 @@ for the method is_logged_in():
     ...         print "Bird is the word"
     ...     else:
     ...         print "Access denied"
-    ... 
+    ...
     >>> @fudge.patch('auth.current_user')
     ... def test_secret_word(current_user):
     ...     user = current_user.expects_call().returns_fake()
     ...     user = user.provides('is_logged_in').returns(True)
     ...     show_secret_word()
-    ... 
+    ...
     >>> test_secret_word()
     Bird is the word
 
@@ -135,18 +135,18 @@ Note that if ``user.is_logged_in()`` is not called then no error will be raised
 Replacing A Method
 ==================
 
-Sometimes returning a static value isn't good enough, you actually need to run some code.  
+Sometimes returning a static value isn't good enough, you actually need to run some code.
 You can do this using :meth:`Fake.calls() <fudge.Fake.calls>` like this:
 
 .. doctest::
-    
+
     >>> auth = fudge.Fake()
     >>> def check_user(username):
     ...     if username=='bert':
     ...         print "Bird is the word"
     ...     else:
     ...         print "Access denied"
-    ... 
+    ...
     >>> auth = auth.provides('show_secret_word_for_user').calls(check_user)
     >>> # Now, the check_user function gets called instead:
     >>> auth.show_secret_word_for_user("bert")
@@ -160,7 +160,7 @@ Cascading Objects
 Some objects you might want to work with will spawn a long chain of objects.  Here is an example of fudging a cascading `SQLAlchemy query <http://www.sqlalchemy.org/docs/05/ormtutorial.html#querying>`_.  Notice that :meth:`Fake.returns_fake() <fudge.Fake.returns_fake>` is used to specify that ``session.query(User)`` should return a new object.  Notice also that because query() should be iterable, it is set to return a list of fake User objects.
 
 .. doctest::
-    
+
     >>> import fudge
     >>> session = fudge.Fake('session')
     >>> query = (session.provides('query')
@@ -173,7 +173,7 @@ Some objects you might want to work with will spawn a long chain of objects.  He
     >>> from models import User
     >>> for instance in session.query(User).order_by(User.id):
     ...     print instance.name, instance.lastname
-    ... 
+    ...
     Al Capone
 
 Multiple Return Values
@@ -182,7 +182,7 @@ Multiple Return Values
 Let's say you want to test code that needs to call a function multiple times and get back multiple values.  Up until now, you've just seen the :meth:`Fake.returns() <fudge.Fake.returns>` method which will return a value infinitely.  To change that, call :meth:`Fake.next_call() <fudge.Fake.next_call>` to advance the call sequence.  Here is an example using a shopping cart scenario:
 
 .. doctest::
-    
+
     >>> cart = (fudge.Fake('cart')
     ...              .provides('add')
     ...              .with_args('book')
@@ -202,17 +202,17 @@ Let's say you want to test code that needs to call a function multiple times and
 Expecting A Specific Call Order
 ===============================
 
-You may need to test an object that expects its methods to be called in a specific order. 
+You may need to test an object that expects its methods to be called in a specific order.
 Just preface any calls to :func:`fudge.Fake.expects` with :func:`fudge.Fake.remember_order` like this:
 
 .. doctest::
-    
+
     >>> import fudge
     >>> session = (fudge.Fake("session").remember_order()
     ...                                 .expects("get_count").returns(0)
     ...                                 .expects("set_count").with_args(5)
     ...                                 .expects("get_count").returns(5))
-    ... 
+    ...
     >>> session.get_count()
     0
     >>> session.set_count(5)
@@ -224,7 +224,7 @@ A descriptive error is printed if you call things out of order:
 
 .. doctest::
     :hide:
-    
+
     >>> fudge.clear_calls()
 
 .. doctest::
@@ -236,7 +236,7 @@ A descriptive error is printed if you call things out of order:
 
 .. doctest::
     :hide:
-    
+
     >>> fudge.clear_expectations()
 
 .. _creating-a-stub:
@@ -250,7 +250,7 @@ attribute will always return a new :class:`fudge.Fake` instance making it
 easier to work complex objects.  Here is an example:
 
 .. doctest::
-  
+
   >>> Server = fudge.Fake('xmlrpclib.Server').is_a_stub()
   >>> pypi = Server('http://pypi.python.org/pypi')
   >>> pypi.list_packages()
@@ -267,7 +267,7 @@ Stubs like this carry on infinitely:
   fake:base.one.two.three().four
 
 .. note::
-  
+
   When using :func:`fudge.Fake.is_a_stub` you can't lazily access any
   attributes or methods if they have the same name as a Fake method,
   like ``returns()`` or ``with_args()``.  You would need to declare
@@ -278,14 +278,14 @@ Stubs like this carry on infinitely:
 Working with Arguments
 ======================
 
-The :func:`fudge.Fake.with_args` method optionally allows you to declare expectations of 
-how arguments should be sent to your object.  It's usually sufficient to expect an exact 
+The :func:`fudge.Fake.with_args` method optionally allows you to declare expectations of
+how arguments should be sent to your object.  It's usually sufficient to expect an exact
 argument value but sometimes you need to use :mod:`fudge.inspector` functions for dynamic values.
 
 Here is a short example:
 
 .. doctest::
-    
+
     >>> import fudge
     >>> from fudge.inspector import arg
     >>> image = (fudge.Fake("image")
@@ -302,10 +302,40 @@ This declaration is very flexible; it allows the following calls:
 
 .. doctest::
     :hide:
-    
+
     >>> fudge.verify()
     >>> fudge.clear_expectations()
-    
+
+The :class:`Fake <fudge.Fake>` class also provides a :meth:`without_args <fudge.Fake.without_args>` method, which functions just the opposite.
+With it, you can declare arguments that you expect NOT to be provided.
+
+.. doctest::
+
+    >>> image = (fudge.Fake('image')
+    ...               .expects('save')
+    ...               .without_args('GIF', filename=arg.endswith('.gif')))
+
+This expectation will pass for any call that does not provide the string ``'GIF'``
+as a positional argument and does not provide a ``filename`` keyword argument that
+ends in ``'.gif'``
+
+.. doctest::
+
+    >>> image.save('JPEG', filename="funny_cat6.jpg")
+    >>> image.save('total nonsense', {'fizz': 'buzz'})
+
+There also inverted version of all the :class:`fudge.inspector.arg <fudge.inspector.ValueInspector>` methods, available on the ``fudge.inspector.arg_not`` object.
+The methods all have the same name, but assert the opposite of the ``arg`` versions.
+See the docstrings for the various :meth:`fudge.inspector.arg <fudge.inspector.ValueInspector>` methods for examples of their usage.
+
+:class:`fudge.inspector.arg_not <fudge.inspector.NotValueInspector>` can also be called on an object to match anything except that object.
+
+.. doctest::
+    :hide:
+
+    >>> fudge.verify()
+    >>> fudge.clear_expectations()
+
 .. _Nose: http://somethingaboutorange.com/mrl/projects/nose/
 .. _py.test: http://codespeak.net/py/dist/test.html
 
@@ -313,5 +343,5 @@ That's it!  See the fudge API for details:
 
 .. toctree::
     :glob:
-    
-    api/*
\ No newline at end of file
+
+    api/*
diff --git a/fudge.egg-info/PKG-INFO b/fudge.egg-info/PKG-INFO
index 7a1ef9e..d57dbae 100644
--- a/fudge.egg-info/PKG-INFO
+++ b/fudge.egg-info/PKG-INFO
@@ -1,8 +1,8 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
 Name: fudge
-Version: 1.0.3
+Version: 1.1.0
 Summary: Replace real objects with fakes (mocks, stubs, etc) while testing.
-Home-page: http://farmdev.com/projects/fudge/
+Home-page: https://github.com/fudge-py/fudge
 Author: Kumar McMillan
 Author-email: kumar.mcmillan at gmail.com
 License: The MIT License
diff --git a/fudge.egg-info/SOURCES.txt b/fudge.egg-info/SOURCES.txt
index 733143b..bb516c6 100644
--- a/fudge.egg-info/SOURCES.txt
+++ b/fudge.egg-info/SOURCES.txt
@@ -1,6 +1,5 @@
 LICENSE.txt
 MANIFEST.in
-README.txt
 run_tests.sh
 setup.py
 docs/Makefile
diff --git a/fudge/.___init__.py b/fudge/.___init__.py
deleted file mode 100644
index 1d8de1f..0000000
Binary files a/fudge/.___init__.py and /dev/null differ
diff --git a/fudge/._inspector.py b/fudge/._inspector.py
deleted file mode 100644
index d1f6f26..0000000
Binary files a/fudge/._inspector.py and /dev/null differ
diff --git a/fudge/._patcher.py b/fudge/._patcher.py
deleted file mode 100644
index c574e99..0000000
Binary files a/fudge/._patcher.py and /dev/null differ
diff --git a/fudge/__init__.py b/fudge/__init__.py
index 4e72ac0..f495539 100644
--- a/fudge/__init__.py
+++ b/fudge/__init__.py
@@ -5,7 +5,7 @@ See :ref:`using-fudge` for common scenarios.
 
 """
 
-__version__ = '1.0.3'
+__version__ = '1.1.0'
 import os
 import re
 import sys
@@ -20,30 +20,30 @@ __all__ = ['Fake', 'patch', 'test', 'clear_calls', 'verify',
 
 class Registry(object):
     """An internal, thread-safe registry of expected calls.
-    
+
     You do not need to use this directly, use Fake.expects(...), etc
     """
-    
+
     def __init__(self):
         self.expected_calls = {}
         self.expected_call_order = {}
         self.call_stacks = []
-    
+
     def __contains__(self, obj):
         return obj in self.get_expected_calls()
-        
+
     def clear_actual_calls(self):
         for exp in self.get_expected_calls():
             exp.was_called = False
-    
+
     def clear_all(self):
         self.clear_actual_calls()
         self.clear_expectations()
-    
+
     def clear_calls(self):
-        """Clears out any calls that were made on previously 
+        """Clears out any calls that were made on previously
         registered fake objects and resets all call stacks.
-        
+
         You do not need to use this directly.  Use fudge.clear_calls()
         """
         self.clear_actual_calls()
@@ -51,13 +51,13 @@ class Registry(object):
             stack.reset()
         for fake, call_order in self.get_expected_call_order().items():
             call_order.reset_calls()
-    
+
     def clear_expectations(self):
         c = self.get_expected_calls()
         c[:] = []
         d = self.get_expected_call_order()
         d.clear()
-        
+
     def expect_call(self, expected_call):
         c = self.get_expected_calls()
         c.append(expected_call)
@@ -65,29 +65,29 @@ class Registry(object):
         if expected_call.fake in call_order:
             this_call_order = call_order[expected_call.fake]
             this_call_order.add_expected_call(expected_call)
-    
+
     def get_expected_calls(self):
         self.expected_calls.setdefault(thread.get_ident(), [])
         return self.expected_calls[thread.get_ident()]
-    
+
     def get_expected_call_order(self):
         self.expected_call_order.setdefault(thread.get_ident(), {})
         return self.expected_call_order[thread.get_ident()]
-    
+
     def remember_expected_call_order(self, expected_call_order):
         ordered_fakes = self.get_expected_call_order()
         fake = expected_call_order.fake
         ## does nothing if called twice like:
         # Fake().remember_order().remember_order()
         ordered_fakes.setdefault(fake, expected_call_order)
-    
+
     def register_call_stack(self, call_stack):
         self.call_stacks.append(call_stack)
-    
+
     def verify(self):
-        """Ensure all expected calls were called, 
+        """Ensure all expected calls were called,
         raise AssertionError otherwise.
-        
+
         You do not need to use this directly.  Use fudge.verify()
         """
         try:
@@ -98,19 +98,19 @@ class Registry(object):
                 call_order.assert_order_met(finalize=True)
         finally:
             self.clear_calls()
-        
+
 registry = Registry()
 
 
 def clear_calls():
     """Begin a new set of calls on fake objects.
-    
-    Specifically, clear out any calls that 
-    were made on previously registered fake 
-    objects and reset all call stacks.  
-    You should call this any time you begin 
+
+    Specifically, clear out any calls that
+    were made on previously registered fake
+    objects and reset all call stacks.
+    You should call this any time you begin
     making calls on fake objects.
-    
+
     This is also available in :func:`fudge.patch`, :func:`fudge.test` and :func:`fudge.with_fakes`
     """
     registry.clear_calls()
@@ -118,12 +118,12 @@ def clear_calls():
 
 def verify():
     """Verify that all methods have been called as expected.
-    
-    Specifically, analyze all registered fake 
-    objects and raise an AssertionError if an 
-    expected call was never made to one or more 
+
+    Specifically, analyze all registered fake
+    objects and raise an AssertionError if an
+    expected call was never made to one or more
     objects.
-    
+
     This is also available in :func:`fudge.patch`, :func:`fudge.test` and :func:`fudge.with_fakes`
     """
     registry.verify()
@@ -133,22 +133,22 @@ def verify():
 
 def start():
     """Start testing with fake objects.
-    
+
     Deprecated.  Use :func:`fudge.clear_calls` instead.
     """
     warnings.warn(
-        "fudge.start() has been deprecated.  Use fudge.clear_calls() instead", 
+        "fudge.start() has been deprecated.  Use fudge.clear_calls() instead",
         DeprecationWarning, 3)
     clear_calls()
 
 
 def stop():
     """Stop testing with fake objects.
-    
+
     Deprecated.  Use :func:`fudge.verify` instead.
     """
     warnings.warn(
-        "fudge.stop() has been deprecated.  Use fudge.verify() instead", 
+        "fudge.stop() has been deprecated.  Use fudge.verify() instead",
         DeprecationWarning, 3)
     verify()
 
@@ -174,27 +174,27 @@ def test(method):
     """Decorator for a test that uses fakes directly (not patched).
 
     Most of the time you probably want to use :func:`fudge.patch` instead.
-    
+
     .. doctest::
         :hide:
-        
+
         >>> import fudge
 
     .. doctest::
-        
+
         >>> @fudge.test
         ... def test():
         ...     db = fudge.Fake('db').expects('connect')
         ...     # do stuff...
-        ... 
+        ...
         >>> test()
         Traceback (most recent call last):
         ...
         AssertionError: fake:db.connect() was not called
-    
+
     .. doctest::
         :hide:
-        
+
         >>> fudge.clear_expectations()
 
     """
@@ -213,21 +213,21 @@ test.__test__ = False # Nose: do not collect
 
 class Call(object):
     """A call that can be made on a Fake object.
-    
+
     You do not need to use this directly, use Fake.provides(...), etc
-    
+
     index=None
-        When numerical, this indicates the position of the call 
+        When numerical, this indicates the position of the call
         (as in, a CallStack)
-    
+
     callable=False
-        Means this object acts like a function, not a method of an 
+        Means this object acts like a function, not a method of an
         object.
-    
+
     call_order=ExpectedCallOrder()
         A call order to append each call to.  Default is None
     """
-    
+
     def __init__(self, fake, call_name=None, index=None,
                  callable=False, call_order=None):
         self.fake = fake
@@ -239,6 +239,8 @@ class Call(object):
         self.expected_kwargs = None
         self.expected_matching_args = None
         self.expected_matching_kwargs = None
+        self.unexpected_args = None
+        self.unexpected_kwargs = None
         self.index = index
         self.exception_to_raise = None
         self.return_val = None
@@ -247,14 +249,14 @@ class Call(object):
         self.actual_times_called = 0
         self.callable = callable
         self.call_order = call_order
-        
+
     def __call__(self, *args, **kwargs):
         self.was_called = True
         self.actual_times_called += 1
         if self.call_order:
             self.call_order.add_actual_call(self)
             self.call_order.assert_order_met(finalize=False)
-        
+
         # make sure call count doesn't go over :
         if self.expected_times_called is not None and \
                 self.actual_times_called > self.expected_times_called:
@@ -262,43 +264,43 @@ class Call(object):
                 '%s was called %s time(s). Expected %s.' % (
                     self, self.actual_times_called,
                     self.expected_times_called))
-        
+
         return_val = None
         replacement_return = None
-        
+
         if self.call_replacement:
             replacement_return = self.call_replacement(*args, **kwargs)
         if self.return_val is not None:
             # this wins:
             return_value = self.return_val
         else:
-            # but it is intuitive to otherwise 
+            # but it is intuitive to otherwise
             # return the replacement's return:
             return_value = replacement_return
-        
+
         # determine whether we should inspect arguments or not:
         with_args = (self.expected_args or self.expected_kwargs)
-        
-        if with_args: 
+
+        if with_args:
             # check keyword args first because of python arg coercion...
             if self.expected_kwargs is None:
                 self.expected_kwargs = {} # empty **kw
             if self.expected_kwargs != kwargs:
                 raise AssertionError(
                     "%s was called unexpectedly with args %s" % (
-                            self, 
+                            self,
                             self._repr_call(args, kwargs,
                                             shorten_long_vals=False)))
-            
+
             if self.expected_args is None:
                 self.expected_args = tuple([]) # empty *args
             if self.expected_args != args:
                 raise AssertionError(
                     "%s was called unexpectedly with args %s" % (
-                            self, 
+                            self,
                             self._repr_call(args, kwargs,
                                             shorten_long_vals=False)))
-        
+
         # now check for matching keyword args.
         # i.e. keyword args that are only checked if the call provided them
         if self.expected_matching_kwargs:
@@ -308,54 +310,70 @@ class Call(object):
                     if expected_value != kwargs[expected_arg]:
                         raise AssertionError(
                             "%s was called unexpectedly with args %s" % (
-                                    self, 
-                                    self._repr_call(args, 
-                                        {expected_arg: kwargs[expected_arg]}, 
+                                    self,
+                                    self._repr_call(args,
+                                        {expected_arg: kwargs[expected_arg]},
                                         shorten_long_vals=False))
                         )
-        
+
         # now check for matching args.
         # i.e. args that are only checked if the call provided them
         if self.expected_matching_args:
             if self.expected_matching_args != args:
                 raise AssertionError(
                     "%s was called unexpectedly with args %s" % (
-                            self, 
+                            self,
                             self._repr_call(args, kwargs,
                                             shorten_long_vals=False)))
-                            
+
         # determine whether we should inspect argument counts or not:
-        with_arg_counts = (self.expected_arg_count is not None or 
+        with_arg_counts = (self.expected_arg_count is not None or
                            self.expected_kwarg_count is not None)
-        
-        if with_arg_counts: 
+
+        if with_arg_counts:
             if self.expected_arg_count is None:
                 self.expected_arg_count = 0
             if len(args) != self.expected_arg_count:
                 raise AssertionError(
                     "%s was called with %s arg(s) but expected %s" % (
                         self, len(args), self.expected_arg_count))
-            
+
             if self.expected_kwarg_count is None:
                 self.expected_kwarg_count = 0
             if len(kwargs.keys()) != self.expected_kwarg_count:
                 raise AssertionError(
                     "%s was called with %s keyword arg(s) but expected %s" % (
                         self, len(kwargs.keys()), self.expected_kwarg_count))
-        
+
+        if self.unexpected_kwargs:
+            for un_key, un_val in self.unexpected_kwargs.items():
+                if un_key in kwargs and kwargs[un_key] == un_val:
+                    raise AssertionError(
+                        "%s was called unexpectedly with kwarg %s=%s" %
+                        (self, un_key, un_val)
+                    )
+
+        if self.unexpected_args:
+            for un_arg in self.unexpected_args:
+                if un_arg in args:
+                    raise AssertionError(
+                        "%s was called unexpectedly with arg %s" %
+                        (self, un_arg)
+                    )
+
         if self.exception_to_raise is not None:
             raise self.exception_to_raise
-        
+
         return return_value
-    
+
     ## hmmm, arg diffing (for Call().__call__()) needs more thought
-        
+
     # def _arg_diff(self, actual_args, expected_args):
     #     """return differnce between keywords"""
     #     if len(actual_args) > len(expected_args):
     #         pass
-    #             
-    # 
+    #
+    #
     # def _keyword_diff(self, actual_kwargs, expected_kwargs):
     #     """returns difference between keywords.
     #     """
@@ -366,19 +384,19 @@ class Call(object):
     #             return (True, "")
     #         else:
     #             return (False, "")
-    #         
+    #
     #     for k,v in actual_kwargs.items():
     #         if k not in expected_keys:
     #             return (False, "keyword %r was not expected" % k)
     #         if v != expected_kwargs[k]:
     #             return (False, "%s=%r != %s=%r" % (k, v, k, expected_kwargs[k]))
     #         expected_keys.remove(k)
-    #     
+    #
     #     exp_key_len = len(expected_keys)
     #     if exp_key_len:
     #         these = exp_key_len==1 and "this keyword" or "these keywords"
     #         return (False, "%s never showed up: %r" % (these, tuple(expected_keys)))
-    #     
+    #
     #     return (True, "")
 
     def _repr_call(self, expected_args, expected_kwargs, shorten_long_vals=True):
@@ -392,7 +410,7 @@ class Call(object):
         else:
             call = "()"
         return call
-    
+
     def __repr__(self):
         cls_name = repr(self.fake)
         if self.call_name and not self.callable:
@@ -403,10 +421,10 @@ class Call(object):
         if self.index is not None:
             call = "%s[%s]" % (call, self.index)
         return call
-    
+
     def get_call_object(self):
         """return self.
-        
+
         this exists for compatibility with :class:`CallStack`
         """
         return self
@@ -417,36 +435,36 @@ class Call(object):
             raise AssertionError(
                 '%s was called %s time(s). Expected %s.' % (
                     self, self.actual_times_called, self.expected_times_called))
-            
-    
... 3339 lines suppressed ...

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



More information about the Python-modules-commits mailing list