Mailinglist Archive: opensuse-commit (849 mails)

< Previous Next >
commit python-minimock for openSUSE:Factory

Hello community,

here is the log from the commit of package python-minimock for openSUSE:Factory
checked in at Mon Mar 7 15:05:32 CET 2011.



--------
--- python-minimock/python-minimock.changes 2009-09-24 16:30:33.000000000
+0200
+++ /mounts/work_src_done/STABLE/python-minimock/python-minimock.changes
2011-02-20 20:52:19.000000000 +0100
@@ -1,0 +2,11 @@
+Sun Feb 20 18:49:13 UTC 2011 - alexandre@xxxxxxxxxxxxxx
+
+- Update to 1.2.6:
+ * Allow changing the tracker on a mock object once it's been set (James
Brady)
+ * Support doctest use case (Israel Tsadok)
+ * Fix issue 1: setting mock_returns_iter on existing Mock object (kenmacd)
+ * Fix issue 2: static methods become unbound methods after mock + restore
+- Bzip2 source file;
+- Spec file cleaned with spec-cleaner.
+
+-------------------------------------------------------------------

calling whatdependson for head-i586


Old:
----
MiniMock-1.2.5.tar.gz

New:
----
MiniMock-1.2.6.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-minimock.spec ++++++
--- /var/tmp/diff_new_pack.2l6x1F/_old 2011-03-07 15:04:51.000000000 +0100
+++ /var/tmp/diff_new_pack.2l6x1F/_new 2011-03-07 15:04:51.000000000 +0100
@@ -1,7 +1,7 @@
#
-# spec file for package python-minimock (Version 1.2.5)
+# spec file for package python-minimock
#
-# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -15,18 +15,18 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

-# norootforbuild


Name: python-minimock
-Version: 1.2.5
+Version: 1.2.6
Release: 1
-Summary: The simplest possible mock library
License: MIT
-Group: Development/Libraries/Python
-Source: MiniMock-%{version}.tar.gz
+Summary: The simplest possible mock library
Url: http://pypi.python.org/pypi/MiniMock
-BuildRequires: python-devel python-setuptools
+Group: Development/Libraries/Python
+Source: MiniMock-%{version}.tar.bz2
+BuildRequires: python-devel
+BuildRequires: python-setuptools
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%{py_requires}
%if %{?suse_version: %{suse_version} > 1110} %{!?suse_version:1}
@@ -40,7 +40,6 @@
--------
Ian Bicking <ianb@xxxxxxxxxxxxxx>

-
%prep
%setup -q -n MiniMock-%{version}

@@ -52,4 +51,5 @@

%files -f INSTALLED_FILES
%defattr(-,root,root)
+
%changelog

++++++ MiniMock-1.2.5.tar.gz -> MiniMock-1.2.6.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/MiniMock-1.2.5/MiniMock.egg-info/PKG-INFO
new/MiniMock-1.2.6/MiniMock.egg-info/PKG-INFO
--- old/MiniMock-1.2.5/MiniMock.egg-info/PKG-INFO 2009-08-07
06:52:52.000000000 +0200
+++ new/MiniMock-1.2.6/MiniMock.egg-info/PKG-INFO 2011-02-19
20:21:40.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: MiniMock
-Version: 1.2.5
+Version: 1.2.6
Summary: The simplest possible mock library
Home-page: http://pypi.python.org/pypi/MiniMock
Author: Ian Bicking
@@ -10,7 +10,7 @@
========

.. contents::
- :depth: 1
+ :depth: 1

--------------------
License & Repository
@@ -40,30 +40,30 @@

Here's an example of something we might test, a simple email sender::

- >>> import smtplib
- >>> def send_email(from_addr, to_addr, subject, body):
- ... conn = smtplib.SMTP('localhost')
- ... msg = 'To: %s\nFrom: %s\nSubject: %s\n\n%s' % (
- ... to_addr, from_addr, subject, body)
- ... conn.sendmail(from_addr, [to_addr], msg)
- ... conn.quit()
+ >>> import smtplib
+ >>> def send_email(from_addr, to_addr, subject, body):
+ ... conn = smtplib.SMTP('localhost')
+ ... msg = 'To: %s\nFrom: %s\nSubject: %s\n\n%s' % (
+ ... to_addr, from_addr, subject, body)
+ ... conn.sendmail(from_addr, [to_addr], msg)
+ ... conn.quit()

Now we want to make a mock ``smtplib.SMTP`` object. We'll have to
inject our mock into the ``smtplib`` module::

- >>> smtplib.SMTP = Mock('smtplib.SMTP')
- >>> smtplib.SMTP.mock_returns = Mock('smtp_connection')
+ >>> smtplib.SMTP = Mock('smtplib.SMTP')
+ >>> smtplib.SMTP.mock_returns = Mock('smtp_connection')

Now we do the test::

- >>> send_email('ianb@xxxxxxxxxxxxxx', 'joe@xxxxxxxxxxx',
- ... 'Hi there!', 'How is it going?')
- Called smtplib.SMTP('localhost')
- Called smtp_connection.sendmail(
- 'ianb@xxxxxxxxxxxxxx',
- ['joe@xxxxxxxxxxx'],
- 'To: joe@xxxxxxxxxxx\nFrom: ianb@xxxxxxxxxxxxxx\nSubject: Hi
there!\n\nHow is it going?')
- Called smtp_connection.quit()
+ >>> send_email('ianb@xxxxxxxxxxxxxx', 'joe@xxxxxxxxxxx',
+ ... 'Hi there!', 'How is it going?')
+ Called smtplib.SMTP('localhost')
+ Called smtp_connection.sendmail(
+ 'ianb@xxxxxxxxxxxxxx',
+ ['joe@xxxxxxxxxxx'],
+ 'To: joe@xxxxxxxxxxx\nFrom: ianb@xxxxxxxxxxxxxx\nSubject: Hi
there!\n\nHow is it going?')
+ Called smtp_connection.quit()

Voila! We've tested implicitly that no unexpected methods were called
on the object. We've also tested the arguments that the mock object
@@ -80,36 +80,42 @@
start with ``mock_``, while the constructor arguments don't.

``name``:
- The name of the object, used when printing out messages. In the
- example about it was ``'smtplib.SMTP'``.
+ The name of the object, used when printing out messages. In the
+ example above it was ``'smtplib.SMTP'``.

``returns``:
- When this object is called, it will return this value. By default
- it is None.
+ When this object is called, it will return this value. By default
+ it is None.

``returns_iter``:
- Alternately, you can give an iterable of return results, like
- ``returns_iter=[1, 2, 3]``; on each subsequent call it will return
- the next value.
+ Alternately, you can give an iterable of return results, like
+ ``returns_iter=[1, 2, 3]``; on each subsequent call it will return
+ the next value.

``returns_func``:
- If given, this will be called to get the return value. In
- essence, this function will be the *real* implementation of the
- method.
-
- ``mock_raises``:
- An exception (instance or class) that will be raised when this
- object is called.
+ If given, this will be called to get the return value. In
+ essence, this function will be the *real* implementation of the
+ method.
+
+ ``raises``:
+ An exception (instance or class) that will be raised when this
+ object is called.
+
+ ``tracker``:
+ An object which is notified every time the mock object is called or
+ an attribute is set on it (assuming ``show_attrs`` is ``True``);
+ defaults to a ``Printer`` to stdout. ``TraceTracker`` can instead
be
+ useful for non-doctest tests. Pass ``None`` to disable this
behavior.

``show_attrs``:
- If this is true, everytime a new attribute is set on the mock
- object something will be printed. Otherwise attribute sets are
- silent, and only function calls print something.
+ If this is true, every time a new attribute is set on the mock
+ object the tracker will be notified. Otherwise attribute sets are
+ silent, and only calls trigger notification.

So to create an object that always raises ValueError, do::

- >>> dummy_module = Mock('mylibrary')
- >>> dummy_module.invalid_func.mock_raises = ValueError
+ >>> dummy_module = Mock('mylibrary')
+ >>> dummy_module.invalid_func.mock_raises = ValueError

--------------
Creating Mocks
@@ -119,9 +125,9 @@
unless you specifically set it to something else. For instance, you
can do::

- >>> from minimock import Mock
- >>> dummy_module = Mock('mylibrary')
- >>> dummy_module.CONSTANT = 1
+ >>> from minimock import Mock
+ >>> dummy_module = Mock('mylibrary')
+ >>> dummy_module.CONSTANT = 1

Then the ``CONSTANT`` value will persist. But you can also traverse
to whatever object you want, and you will get another mock object.
@@ -129,9 +135,9 @@
Another technique for creating a mock object is the ``mock(...)``
function. This works like::

- >>> from minimock import mock
- >>> import os.path
- >>> mock('os.path.isfile', returns=True)
+ >>> from minimock import mock
+ >>> import os.path
+ >>> mock('os.path.isfile', returns=True)

This looks up the ``os.path.isfile`` object, and changes it to a mock
object. Any keyword arguments you give (like ``returns=True`` in this
@@ -152,9 +158,19 @@
News
----

- trunk
+ hg tip
+ ------
+ *
+
+ 1.2.6
-----
+ * Allow changing the tracker on a mock object once it's been set
(James Brady)
+ * Support doctest use case (Israel Tsadok)
+ * Fix issue 1: setting mock_returns_iter on existing Mock object
(kenmacd)
+ * Fix issue 2: static methods become unbound methods after mock +
restore

+ 1.2.5
+ -----
* Deprecate ``MockTracker``. ``TraceTracker`` should be used instead.

1.2.4
@@ -165,15 +181,15 @@
-----

* Explicitly passing ``tracker=None`` to the ``Mock`` constructor now
- suppresses tracking. If ``tracker`` is not passed it will still use
- ``Printer(sys.stdout)`` as before.
+ suppresses tracking. If ``tracker`` is not passed it will still use
+ ``Printer(sys.stdout)`` as before.

1.2.2
-----

* Added ``MinimockOutputChecker`` which normalizes whitespace in
function call
- traces; ``TraceTracker`` now uses this instead of
``doctest.OutputChecker``
- (Ben Finney)
+ traces; ``TraceTracker`` now uses this instead of
``doctest.OutputChecker``
+ (Ben Finney)

1.2.1
-----
@@ -194,10 +210,10 @@
---

* Fixed setting special attributes like ``mock_returns`` on
- already-created Mock objects (Toby White)
+ already-created Mock objects (Toby White)

* Separated out printing to a class that accepts call information
- and provided an implementation that prints calls to a file.
+ and provided an implementation that prints calls to a file.

0.9
---
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/MiniMock-1.2.5/MiniMock.egg-info/SOURCES.txt
new/MiniMock-1.2.6/MiniMock.egg-info/SOURCES.txt
--- old/MiniMock-1.2.5/MiniMock.egg-info/SOURCES.txt 2009-08-07
06:52:52.000000000 +0200
+++ new/MiniMock-1.2.6/MiniMock.egg-info/SOURCES.txt 2011-02-19
20:21:40.000000000 +0100
@@ -7,6 +7,7 @@
MiniMock.egg-info/dependency_links.txt
MiniMock.egg-info/top_level.txt
MiniMock.egg-info/zip-safe
-docs/changelog.txt
-docs/index.txt
+docs/.changelog.rst.un~
+docs/changelog.rst
+docs/index.rst
docs/license.txt
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/MiniMock-1.2.5/PKG-INFO new/MiniMock-1.2.6/PKG-INFO
--- old/MiniMock-1.2.5/PKG-INFO 2009-08-07 06:52:53.000000000 +0200
+++ new/MiniMock-1.2.6/PKG-INFO 2011-02-19 20:21:41.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: MiniMock
-Version: 1.2.5
+Version: 1.2.6
Summary: The simplest possible mock library
Home-page: http://pypi.python.org/pypi/MiniMock
Author: Ian Bicking
@@ -10,7 +10,7 @@
========

.. contents::
- :depth: 1
+ :depth: 1

--------------------
License & Repository
@@ -40,30 +40,30 @@

Here's an example of something we might test, a simple email sender::

- >>> import smtplib
- >>> def send_email(from_addr, to_addr, subject, body):
- ... conn = smtplib.SMTP('localhost')
- ... msg = 'To: %s\nFrom: %s\nSubject: %s\n\n%s' % (
- ... to_addr, from_addr, subject, body)
- ... conn.sendmail(from_addr, [to_addr], msg)
- ... conn.quit()
+ >>> import smtplib
+ >>> def send_email(from_addr, to_addr, subject, body):
+ ... conn = smtplib.SMTP('localhost')
+ ... msg = 'To: %s\nFrom: %s\nSubject: %s\n\n%s' % (
+ ... to_addr, from_addr, subject, body)
+ ... conn.sendmail(from_addr, [to_addr], msg)
+ ... conn.quit()

Now we want to make a mock ``smtplib.SMTP`` object. We'll have to
inject our mock into the ``smtplib`` module::

- >>> smtplib.SMTP = Mock('smtplib.SMTP')
- >>> smtplib.SMTP.mock_returns = Mock('smtp_connection')
+ >>> smtplib.SMTP = Mock('smtplib.SMTP')
+ >>> smtplib.SMTP.mock_returns = Mock('smtp_connection')

Now we do the test::

- >>> send_email('ianb@xxxxxxxxxxxxxx', 'joe@xxxxxxxxxxx',
- ... 'Hi there!', 'How is it going?')
- Called smtplib.SMTP('localhost')
- Called smtp_connection.sendmail(
- 'ianb@xxxxxxxxxxxxxx',
- ['joe@xxxxxxxxxxx'],
- 'To: joe@xxxxxxxxxxx\nFrom: ianb@xxxxxxxxxxxxxx\nSubject: Hi
there!\n\nHow is it going?')
- Called smtp_connection.quit()
+ >>> send_email('ianb@xxxxxxxxxxxxxx', 'joe@xxxxxxxxxxx',
+ ... 'Hi there!', 'How is it going?')
+ Called smtplib.SMTP('localhost')
+ Called smtp_connection.sendmail(
+ 'ianb@xxxxxxxxxxxxxx',
+ ['joe@xxxxxxxxxxx'],
+ 'To: joe@xxxxxxxxxxx\nFrom: ianb@xxxxxxxxxxxxxx\nSubject: Hi
there!\n\nHow is it going?')
+ Called smtp_connection.quit()

Voila! We've tested implicitly that no unexpected methods were called
on the object. We've also tested the arguments that the mock object
@@ -80,36 +80,42 @@
start with ``mock_``, while the constructor arguments don't.

``name``:
- The name of the object, used when printing out messages. In the
- example about it was ``'smtplib.SMTP'``.
+ The name of the object, used when printing out messages. In the
+ example above it was ``'smtplib.SMTP'``.

``returns``:
- When this object is called, it will return this value. By default
- it is None.
+ When this object is called, it will return this value. By default
+ it is None.

``returns_iter``:
- Alternately, you can give an iterable of return results, like
- ``returns_iter=[1, 2, 3]``; on each subsequent call it will return
- the next value.
+ Alternately, you can give an iterable of return results, like
+ ``returns_iter=[1, 2, 3]``; on each subsequent call it will return
+ the next value.

``returns_func``:
- If given, this will be called to get the return value. In
- essence, this function will be the *real* implementation of the
- method.
-
- ``mock_raises``:
- An exception (instance or class) that will be raised when this
- object is called.
+ If given, this will be called to get the return value. In
+ essence, this function will be the *real* implementation of the
+ method.
+
+ ``raises``:
+ An exception (instance or class) that will be raised when this
+ object is called.
+
+ ``tracker``:
+ An object which is notified every time the mock object is called or
+ an attribute is set on it (assuming ``show_attrs`` is ``True``);
+ defaults to a ``Printer`` to stdout. ``TraceTracker`` can instead
be
+ useful for non-doctest tests. Pass ``None`` to disable this
behavior.

``show_attrs``:
- If this is true, everytime a new attribute is set on the mock
- object something will be printed. Otherwise attribute sets are
- silent, and only function calls print something.
+ If this is true, every time a new attribute is set on the mock
+ object the tracker will be notified. Otherwise attribute sets are
+ silent, and only calls trigger notification.

So to create an object that always raises ValueError, do::

- >>> dummy_module = Mock('mylibrary')
- >>> dummy_module.invalid_func.mock_raises = ValueError
+ >>> dummy_module = Mock('mylibrary')
+ >>> dummy_module.invalid_func.mock_raises = ValueError

--------------
Creating Mocks
@@ -119,9 +125,9 @@
unless you specifically set it to something else. For instance, you
can do::

- >>> from minimock import Mock
- >>> dummy_module = Mock('mylibrary')
- >>> dummy_module.CONSTANT = 1
+ >>> from minimock import Mock
+ >>> dummy_module = Mock('mylibrary')
+ >>> dummy_module.CONSTANT = 1

Then the ``CONSTANT`` value will persist. But you can also traverse
to whatever object you want, and you will get another mock object.
@@ -129,9 +135,9 @@
Another technique for creating a mock object is the ``mock(...)``
function. This works like::

- >>> from minimock import mock
- >>> import os.path
- >>> mock('os.path.isfile', returns=True)
+ >>> from minimock import mock
+ >>> import os.path
+ >>> mock('os.path.isfile', returns=True)

This looks up the ``os.path.isfile`` object, and changes it to a mock
object. Any keyword arguments you give (like ``returns=True`` in this
@@ -152,9 +158,19 @@
News
----

- trunk
+ hg tip
+ ------
+ *
+
+ 1.2.6
-----
+ * Allow changing the tracker on a mock object once it's been set
(James Brady)
+ * Support doctest use case (Israel Tsadok)
+ * Fix issue 1: setting mock_returns_iter on existing Mock object
(kenmacd)
+ * Fix issue 2: static methods become unbound methods after mock +
restore

+ 1.2.5
+ -----
* Deprecate ``MockTracker``. ``TraceTracker`` should be used instead.

1.2.4
@@ -165,15 +181,15 @@
-----

* Explicitly passing ``tracker=None`` to the ``Mock`` constructor now
- suppresses tracking. If ``tracker`` is not passed it will still use
- ``Printer(sys.stdout)`` as before.
+ suppresses tracking. If ``tracker`` is not passed it will still use
+ ``Printer(sys.stdout)`` as before.

1.2.2
-----

* Added ``MinimockOutputChecker`` which normalizes whitespace in
function call
- traces; ``TraceTracker`` now uses this instead of
``doctest.OutputChecker``
- (Ben Finney)
+ traces; ``TraceTracker`` now uses this instead of
``doctest.OutputChecker``
+ (Ben Finney)

1.2.1
-----
@@ -194,10 +210,10 @@
---

* Fixed setting special attributes like ``mock_returns`` on
- already-created Mock objects (Toby White)
+ already-created Mock objects (Toby White)

* Separated out printing to a class that accepts call information
- and provided an implementation that prints calls to a file.
+ and provided an implementation that prints calls to a file.

0.9
---
Files old/MiniMock-1.2.5/docs/.changelog.rst.un~ and
new/MiniMock-1.2.6/docs/.changelog.rst.un~ differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/MiniMock-1.2.5/docs/changelog.rst
new/MiniMock-1.2.6/docs/changelog.rst
--- old/MiniMock-1.2.5/docs/changelog.rst 1970-01-01 01:00:00.000000000
+0100
+++ new/MiniMock-1.2.6/docs/changelog.rst 2011-02-19 20:17:46.000000000
+0100
@@ -0,0 +1,70 @@
+----
+News
+----
+
+hg tip
+------
+*
+
+1.2.6
+-----
+* Allow changing the tracker on a mock object once it's been set (James Brady)
+* Support doctest use case (Israel Tsadok)
+* Fix issue 1: setting mock_returns_iter on existing Mock object (kenmacd)
+* Fix issue 2: static methods become unbound methods after mock + restore
+
+1.2.5
+-----
+* Deprecate ``MockTracker``. ``TraceTracker`` should be used instead.
+
+1.2.4
+-----
+* Fix show_attrs=True bug (Kendrick Shaw)
+
+1.2.3
+-----
+
+* Explicitly passing ``tracker=None`` to the ``Mock`` constructor now
+ suppresses tracking. If ``tracker`` is not passed it will still use
+ ``Printer(sys.stdout)`` as before.
+
+1.2.2
+-----
+
+* Added ``MinimockOutputChecker`` which normalizes whitespace in function call
+ traces; ``TraceTracker`` now uses this instead of ``doctest.OutputChecker``
+ (Ben Finney)
+
+1.2.1
+-----
+
+* Allow mocking of built-in functions.
+
+1.2
+---
+
+* Added ``TraceTracker``, a better ``Tracker`` to use with unittests (James
Brady)
+
+1.1
+---
+
+* Added ``MockTracker`` for use with unittests rather than doctests (James
Brady)
+
+1.0
+---
+
+* Fixed setting special attributes like ``mock_returns`` on
+ already-created Mock objects (Toby White)
+
+* Separated out printing to a class that accepts call information
+ and provided an implementation that prints calls to a file.
+
+0.9
+---
+
+* Added ``show_attrs``
+
+0.8
+---
+
+First official release.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/MiniMock-1.2.5/docs/changelog.txt
new/MiniMock-1.2.6/docs/changelog.txt
--- old/MiniMock-1.2.5/docs/changelog.txt 2009-08-07 06:49:15.000000000
+0200
+++ new/MiniMock-1.2.6/docs/changelog.txt 1970-01-01 01:00:00.000000000
+0100
@@ -1,60 +0,0 @@
-----
-News
-----
-
-trunk
------
-
-* Deprecate ``MockTracker``. ``TraceTracker`` should be used instead.
-
-1.2.4
------
-* Fix show_attrs=True bug (Kendrick Shaw)
-
-1.2.3
------
-
-* Explicitly passing ``tracker=None`` to the ``Mock`` constructor now
- suppresses tracking. If ``tracker`` is not passed it will still use
- ``Printer(sys.stdout)`` as before.
-
-1.2.2
------
-
-* Added ``MinimockOutputChecker`` which normalizes whitespace in function call
- traces; ``TraceTracker`` now uses this instead of ``doctest.OutputChecker``
- (Ben Finney)
-
-1.2.1
------
-
-* Allow mocking of built-in functions.
-
-1.2
----
-
-* Added ``TraceTracker``, a better ``Tracker`` to use with unittests (James
Brady)
-
-1.1
----
-
-* Added ``MockTracker`` for use with unittests rather than doctests (James
Brady)
-
-1.0
----
-
-* Fixed setting special attributes like ``mock_returns`` on
- already-created Mock objects (Toby White)
-
-* Separated out printing to a class that accepts call information
- and provided an implementation that prints calls to a file.
-
-0.9
----
-
-* Added ``show_attrs``
-
-0.8
----
-
-First official release.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/MiniMock-1.2.5/docs/index.rst
new/MiniMock-1.2.6/docs/index.rst
--- old/MiniMock-1.2.5/docs/index.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/MiniMock-1.2.6/docs/index.rst 2009-11-29 18:06:17.000000000 +0100
@@ -0,0 +1,147 @@
+MiniMock
+========
+
+.. contents::
+ :depth: 1
+
+--------------------
+License & Repository
+--------------------
+
+MiniMock is by `Ian Bicking <http://blog.ianbicking.org>`_ with
+substantial contributions by Mike Beachy, and is maintained by Josh
+Bronson. It is licensed under an `MIT-style license
+<http://bitbucket.org/jab/minimock/src/tip/docs/license.txt>`_.
+
+It has a `bitbucket repository <http://bitbucket.org/jab/minimock/>`_
+which you can clone with ``hg clone https://jab@xxxxxxxxxxxxx/jab/minimock/``,
+download an archive of the tip from
+`http://bitbucket.org/jab/minimock/get/tip.gz
+<http://bitbucket.org/jab/minimock/get/tip.gz#egg=MiniMock-dev>`_,
+or install from with ``easy_install MiniMock==dev``.
+There is also a `Google Group <http://groups.google.com/group/minimock-dev>`_
+for the development mailing list which can be emailed at
+`minimock-dev@xxxxxxxxxxxxxxxx <mailto:minimock-dev@xxxxxxxxxxxxxxxx>`_.
+
+------------
+Introduction
+------------
+
+minimock is a simple library for doing Mock objects with doctest.
+When using doctest, mock objects can be very simple.
+
+Here's an example of something we might test, a simple email sender::
+
+ >>> import smtplib
+ >>> def send_email(from_addr, to_addr, subject, body):
+ ... conn = smtplib.SMTP('localhost')
+ ... msg = 'To: %s\nFrom: %s\nSubject: %s\n\n%s' % (
+ ... to_addr, from_addr, subject, body)
+ ... conn.sendmail(from_addr, [to_addr], msg)
+ ... conn.quit()
+
+Now we want to make a mock ``smtplib.SMTP`` object. We'll have to
+inject our mock into the ``smtplib`` module::
+
+ >>> smtplib.SMTP = Mock('smtplib.SMTP')
+ >>> smtplib.SMTP.mock_returns = Mock('smtp_connection')
+
+Now we do the test::
+
+ >>> send_email('ianb@xxxxxxxxxxxxxx', 'joe@xxxxxxxxxxx',
+ ... 'Hi there!', 'How is it going?')
+ Called smtplib.SMTP('localhost')
+ Called smtp_connection.sendmail(
+ 'ianb@xxxxxxxxxxxxxx',
+ ['joe@xxxxxxxxxxx'],
+ 'To: joe@xxxxxxxxxxx\nFrom: ianb@xxxxxxxxxxxxxx\nSubject: Hi
there!\n\nHow is it going?')
+ Called smtp_connection.quit()
+
+Voila! We've tested implicitly that no unexpected methods were called
+on the object. We've also tested the arguments that the mock object
+got. We've provided fake return calls (for the ``smtplib.SMTP()``
+constructor). These are all the core parts of a mock library. The
+implementation is simple because most of the work is done by doctest.
+
+-----------------
+Controlling Mocks
+-----------------
+
+Mock objects have several attributes, all of which you can set when
+instantiating the object. To avoid name collision, all the attributes
+start with ``mock_``, while the constructor arguments don't.
+
+``name``:
+ The name of the object, used when printing out messages. In the
+ example above it was ``'smtplib.SMTP'``.
+
+``returns``:
+ When this object is called, it will return this value. By default
+ it is None.
+
+``returns_iter``:
+ Alternately, you can give an iterable of return results, like
+ ``returns_iter=[1, 2, 3]``; on each subsequent call it will return
+ the next value.
+
+``returns_func``:
+ If given, this will be called to get the return value. In
+ essence, this function will be the *real* implementation of the
+ method.
+
+``raises``:
+ An exception (instance or class) that will be raised when this
+ object is called.
+
+``tracker``:
+ An object which is notified every time the mock object is called or
+ an attribute is set on it (assuming ``show_attrs`` is ``True``);
+ defaults to a ``Printer`` to stdout. ``TraceTracker`` can instead be
+ useful for non-doctest tests. Pass ``None`` to disable this behavior.
+
+``show_attrs``:
+ If this is true, every time a new attribute is set on the mock
+ object the tracker will be notified. Otherwise attribute sets are
+ silent, and only calls trigger notification.
+
+So to create an object that always raises ValueError, do::
+
+ >>> dummy_module = Mock('mylibrary')
+ >>> dummy_module.invalid_func.mock_raises = ValueError
+
+--------------
+Creating Mocks
+--------------
+
+Every attribute of a mock object will itself be another mock object,
+unless you specifically set it to something else. For instance, you
+can do::
+
+ >>> from minimock import Mock
+ >>> dummy_module = Mock('mylibrary')
+ >>> dummy_module.CONSTANT = 1
+
+Then the ``CONSTANT`` value will persist. But you can also traverse
+to whatever object you want, and you will get another mock object.
+
+Another technique for creating a mock object is the ``mock(...)``
+function. This works like::
+
+ >>> from minimock import mock
+ >>> import os.path
+ >>> mock('os.path.isfile', returns=True)
+
+This looks up the ``os.path.isfile`` object, and changes it to a mock
+object. Any keyword arguments you give (like ``returns=True`` in this
+example) will be used to create the mock object; you can also give a
+``mock_obj`` keyword argument to pass in a mock object you've already
+created.
+
+This function looks in the calling function to figure out what to
+replace (``os.path.isfile`` in the example). You must import the
+proper modules first. Alternately you can pass in a dictionary like
+``[locals(), globals()]`` for it to use for lookup.
+
+To restore all the objects mocked with ``mock()``, use
+``minimock.restore()`` (with no arguments; all the mocks are kept
+track of).
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/MiniMock-1.2.5/docs/index.txt
new/MiniMock-1.2.6/docs/index.txt
--- old/MiniMock-1.2.5/docs/index.txt 2009-08-07 06:49:23.000000000 +0200
+++ new/MiniMock-1.2.6/docs/index.txt 1970-01-01 01:00:00.000000000 +0100
@@ -1,141 +0,0 @@
-MiniMock
-========
-
-.. contents::
- :depth: 1
-
---------------------
-License & Repository
---------------------
-
-MiniMock is by `Ian Bicking <http://blog.ianbicking.org>`_ with
-substantial contributions by Mike Beachy, and is maintained by Josh
-Bronson. It is licensed under an `MIT-style license
-<http://bitbucket.org/jab/minimock/src/tip/docs/license.txt>`_.
-
-It has a `bitbucket repository <http://bitbucket.org/jab/minimock/>`_
-which you can clone with ``hg clone https://jab@xxxxxxxxxxxxx/jab/minimock/``,
-download an archive of the tip from
-`http://bitbucket.org/jab/minimock/get/tip.gz
-<http://bitbucket.org/jab/minimock/get/tip.gz#egg=MiniMock-dev>`_,
-or install from with ``easy_install MiniMock==dev``.
-There is also a `Google Group <http://groups.google.com/group/minimock-dev>`_
-for the development mailing list which can be emailed at
-`minimock-dev@xxxxxxxxxxxxxxxx <mailto:minimock-dev@xxxxxxxxxxxxxxxx>`_.
-
-------------
-Introduction
-------------
-
-minimock is a simple library for doing Mock objects with doctest.
-When using doctest, mock objects can be very simple.
-
-Here's an example of something we might test, a simple email sender::
-
- >>> import smtplib
- >>> def send_email(from_addr, to_addr, subject, body):
- ... conn = smtplib.SMTP('localhost')
- ... msg = 'To: %s\nFrom: %s\nSubject: %s\n\n%s' % (
- ... to_addr, from_addr, subject, body)
- ... conn.sendmail(from_addr, [to_addr], msg)
- ... conn.quit()
-
-Now we want to make a mock ``smtplib.SMTP`` object. We'll have to
-inject our mock into the ``smtplib`` module::
-
- >>> smtplib.SMTP = Mock('smtplib.SMTP')
- >>> smtplib.SMTP.mock_returns = Mock('smtp_connection')
-
-Now we do the test::
-
- >>> send_email('ianb@xxxxxxxxxxxxxx', 'joe@xxxxxxxxxxx',
- ... 'Hi there!', 'How is it going?')
- Called smtplib.SMTP('localhost')
- Called smtp_connection.sendmail(
- 'ianb@xxxxxxxxxxxxxx',
- ['joe@xxxxxxxxxxx'],
- 'To: joe@xxxxxxxxxxx\nFrom: ianb@xxxxxxxxxxxxxx\nSubject: Hi
there!\n\nHow is it going?')
- Called smtp_connection.quit()
-
-Voila! We've tested implicitly that no unexpected methods were called
-on the object. We've also tested the arguments that the mock object
-got. We've provided fake return calls (for the ``smtplib.SMTP()``
-constructor). These are all the core parts of a mock library. The
-implementation is simple because most of the work is done by doctest.
-
------------------
-Controlling Mocks
------------------
-
-Mock objects have several attributes, all of which you can set when
-instantiating the object. To avoid name collision, all the attributes
-start with ``mock_``, while the constructor arguments don't.
-
-``name``:
- The name of the object, used when printing out messages. In the
- example about it was ``'smtplib.SMTP'``.
-
-``returns``:
- When this object is called, it will return this value. By default
- it is None.
-
-``returns_iter``:
- Alternately, you can give an iterable of return results, like
- ``returns_iter=[1, 2, 3]``; on each subsequent call it will return
- the next value.
-
-``returns_func``:
- If given, this will be called to get the return value. In
- essence, this function will be the *real* implementation of the
- method.
-
-``mock_raises``:
- An exception (instance or class) that will be raised when this
- object is called.
-
-``show_attrs``:
- If this is true, everytime a new attribute is set on the mock
- object something will be printed. Otherwise attribute sets are
- silent, and only function calls print something.
-
-So to create an object that always raises ValueError, do::
-
- >>> dummy_module = Mock('mylibrary')
- >>> dummy_module.invalid_func.mock_raises = ValueError
-
---------------
-Creating Mocks
---------------
-
-Every attribute of a mock object will itself be another mock object,
-unless you specifically set it to something else. For instance, you
-can do::
-
- >>> from minimock import Mock
- >>> dummy_module = Mock('mylibrary')
- >>> dummy_module.CONSTANT = 1
-
-Then the ``CONSTANT`` value will persist. But you can also traverse
-to whatever object you want, and you will get another mock object.
-
-Another technique for creating a mock object is the ``mock(...)``
-function. This works like::
-
- >>> from minimock import mock
- >>> import os.path
- >>> mock('os.path.isfile', returns=True)
-
-This looks up the ``os.path.isfile`` object, and changes it to a mock
-object. Any keyword arguments you give (like ``returns=True`` in this
-example) will be used to create the mock object; you can also give a
-``mock_obj`` keyword argument to pass in a mock object you've already
-created.
-
-This function looks in the calling function to figure out what to
-replace (``os.path.isfile`` in the example). You must import the
-proper modules first. Alternately you can pass in a dictionary like
-``[locals(), globals()]`` for it to use for lookup.
-
-To restore all the objects mocked with ``mock()``, use
-``minimock.restore()`` (with no arguments; all the mocks are kept
-track of).
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/MiniMock-1.2.5/minimock.py
new/MiniMock-1.2.6/minimock.py
--- old/MiniMock-1.2.5/minimock.py 2009-08-07 06:49:15.000000000 +0200
+++ new/MiniMock-1.2.6/minimock.py 2011-02-19 20:02:26.000000000 +0100
@@ -60,9 +60,9 @@
"""
Look up an object by name from a sequence of namespace dictionaries.
Returns a tuple of (nsdict, object, attributes); nsdict is the
- dictionary the name was found in, object is the base object the name is
- bound to, and the attributes list is the chain of attributes of the
- object that complete the name.
+ dictionary the name was found in, object is the name of the base object
+ the name is bound to, and the attributes list is the chain of attributes
+ of the object that complete the name.

>>> import os
>>> nsdict, name, attributes = lookup_by_name("os.path.isdir",
@@ -106,7 +106,7 @@
All additional keyword args are passed on to the Mock object
initializer.

- An example of how os.path.isfile is replaced:
+ An example of how os.path.isfile is replaced::

>>> import os
>>> os.path.isfile
@@ -134,11 +134,36 @@
>>> isfile_id == id(os.path.isfile)
True

- Test mocking a built-in function:
+ Test mocking a built-in function::
+
>>> mock("raw_input", returns="okay")
>>> raw_input()
Called raw_input()
'okay'
+ >>> restore()
+
+ Test mocking and restoring a classmethod and staticmethod::
+
+ >>> class Test(object):
+ ... @classmethod
+ ... def cm(cls):
+ ... return 'cm'
+ ... @staticmethod
+ ... def sm():
+ ... return 'sm'
+ >>> mock('Test.cm', returns='mocked')
+ >>> mock('Test.sm', returns='mocked')
+ >>> Test.cm()
+ Called Test.cm()
+ 'mocked'
+ >>> Test.sm()
+ Called Test.sm()
+ 'mocked'
+ >>> restore()
+ >>> Test.cm()
+ 'cm'
+ >>> Test.sm()
+ 'sm'

"""
if nsdicts is None:
@@ -158,13 +183,21 @@

# Get the original object and replace it with the mock object.
tmp = nsdict[obj_name]
+
+ # if run from a doctest, nsdict may point to a *copy* of the
+ # global namespace, so instead use tmp.func_globals if present.
+ # we use isinstance(gettattr(...), dict) rather than hasattr
+ # because if tmp is itself a mock object, tmp.func_globals will
+ # return another mock object
+ if isinstance(getattr(tmp, 'func_globals', None), dict):
+ nsdict = tmp.func_globals
if not attrs:
original = tmp
nsdict[obj_name] = mock_obj
else:
for attr in attrs[:-1]:
- tmp = getattr(tmp, attr)
- original = getattr(tmp, attrs[-1])
+ tmp = tmp.__dict__[attr]
+ original = tmp.__dict__[attrs[-1]]
setattr(tmp, attrs[-1], mock_obj)

mocked.append((original, nsdict, obj_name, attrs))
@@ -184,9 +217,8 @@
else:
tmp = nsdict[name]
for attr in attrs[:-1]:
- tmp = getattr(tmp, attr)
+ tmp = tmp.__dict__[attr]
setattr(tmp, attrs[-1], original)
- return

def assert_same_trace(tracker, want):
r"""
@@ -417,18 +449,19 @@
def __init__(self, name, returns=None, returns_iter=None,
returns_func=None, raises=None, show_attrs=False,
tracker=DefaultTracker, **kw):
- object.__setattr__(self, 'mock_name', name)
- object.__setattr__(self, 'mock_returns', returns)
+ _obsetattr = object.__setattr__
+ _obsetattr(self, 'mock_name', name)
+ _obsetattr(self, 'mock_returns', returns)
if returns_iter is not None:
returns_iter = iter(returns_iter)
- object.__setattr__(self, 'mock_returns_iter', returns_iter)
- object.__setattr__(self, 'mock_returns_func', returns_func)
- object.__setattr__(self, 'mock_raises', raises)
- object.__setattr__(self, 'mock_attrs', kw)
- object.__setattr__(self, 'mock_show_attrs', show_attrs)
+ _obsetattr(self, 'mock_returns_iter', returns_iter)
+ _obsetattr(self, 'mock_returns_func', returns_func)
+ _obsetattr(self, 'mock_raises', raises)
+ _obsetattr(self, 'mock_attrs', kw)
+ _obsetattr(self, 'mock_show_attrs', show_attrs)
if tracker is DefaultTracker:
tracker = Printer(sys.stdout)
- object.__setattr__(self, 'mock_tracker', tracker)
+ _obsetattr(self, 'mock_tracker', tracker)

def __repr__(self):
return '<Mock %s %s>' % (hex(id(self)), self.mock_name)
@@ -465,7 +498,16 @@
return self.mock_attrs[attr]

def __setattr__(self, attr, value):
- if attr in ["mock_raises", "mock_returns", "mock_returns_func",
"mock_returns_iter", "mock_returns_func", "show_attrs"]:
+ if attr in frozenset((
+ 'mock_raises',
+ 'mock_returns',
+ 'mock_returns_func',
+ 'mock_returns_iter',
+ 'mock_tracker',
+ 'show_attrs',
+ )):
+ if attr == 'mock_returns_iter' and value is not None:
+ value = iter(value)
object.__setattr__(self, attr, value)
else:
if self.mock_show_attrs and self.mock_tracker is not None:
@@ -473,6 +515,34 @@
self.mock_attrs[attr] = value

__test__ = {
+ "Mock" :
+ r"""
+ Test setting various "mock_" attributes on an existing Mock object.
+
+ >>> m = Mock('mock_obj', tracker=None)
+ >>> m.mock_returns = 42
+ >>> m()
+ 42
+ >>> m.mock_returns = None
+ >>> m.mock_returns_func = lambda x: x*x
+ >>> m(3)
+ 9
+ >>> m.mock_returns_func = None
+ >>> m.mock_returns_iter = [True, False]
+ >>> m()
+ True
+ >>> m()
+ False
+ >>> m.mock_returns_iter = None
+ >>> m.mock_raises = ValueError
+ >>> try:
+ ... m()
+ ... except ValueError:
+ ... pass
+ ... else:
+ ... raise AssertionError('m() should have raised ValueError')
+ """,
+
"mock" :
r"""
An additional test for mocking a function accessed directly (i.e.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/MiniMock-1.2.5/setup.py new/MiniMock-1.2.6/setup.py
--- old/MiniMock-1.2.5/setup.py 2009-08-07 06:49:15.000000000 +0200
+++ new/MiniMock-1.2.6/setup.py 2011-02-19 20:14:56.000000000 +0100
@@ -1,31 +1,31 @@
-from setuptools import setup, find_packages
-import sys, os
+from setuptools import setup

-version = '1.2.5'
+version = '1.2.6'

try:
- doc_dir = os.path.join(os.path.dirname(__file__), 'docs')
- index = open(os.path.join(doc_dir, 'index.txt')).read()
- changelog = open(os.path.join(doc_dir, 'changelog.txt')).read()
+ from os.path import join, dirname
+ doc_dir = join(dirname(__file__), 'docs')
+ index = open(join(doc_dir, 'index.rst')).read()
+ changelog = open(join(doc_dir, 'changelog.rst')).read()
long_description = '\n'.join((index, changelog))
except IOError:
- long_description = 'Please see docs/index.txt for more info'
+ long_description = 'Please see docs/index.rst for more info'

-setup(name='MiniMock',
- version=version,
- description="The simplest possible mock library",
- long_description=long_description,
- classifiers=[
- "Development Status :: 5 - Production/Stable",
- "License :: OSI Approved :: MIT License",
- "Topic :: Software Development :: Testing",
- ],
- keywords='mock testing unittest',
- author='Ian Bicking',
- author_email='ianb@xxxxxxxxxxxxxx',
- url='http://pypi.python.org/pypi/MiniMock',
- license='MIT',
- #packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
- py_modules=['minimock'],
- zip_safe=True,
- )
+setup(
+ name='MiniMock',
+ version=version,
+ description='The simplest possible mock library',
+ long_description=long_description,
+ classifiers=[
+ 'Development Status :: 5 - Production/Stable',
+ 'License :: OSI Approved :: MIT License',
+ 'Topic :: Software Development :: Testing',
+ ],
+ keywords='mock testing unittest',
+ author='Ian Bicking',
+ author_email='ianb@xxxxxxxxxxxxxx',
+ url='http://pypi.python.org/pypi/MiniMock',
+ license='MIT',
+ py_modules=['minimock'],
+ zip_safe=True,
+ )


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Remember to have fun...

--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages