Hello community,
here is the log from the commit of package python3-mock for openSUSE:Factory checked in at 2016-04-14 13:01:14
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python3-mock (Old)
and /work/SRC/openSUSE:Factory/.python3-mock.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-mock"
Changes:
--------
--- /work/SRC/openSUSE:Factory/python3-mock/python3-mock-doc.changes 2015-10-24 10:23:01.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.python3-mock.new/python3-mock-doc.changes 2016-04-14 13:01:15.000000000 +0200
@@ -1,0 +2,31 @@
+Sat Apr 9 16:43:52 UTC 2016 - arun@gmx.de
+
+- specfile:
+ * update copyright year
+
+- update to version 2.0.0:
+ * Fix #338: depend on a fixed version of funcsigs
+ * More 3.2 support dropping cleanup
+ * Update sync point
+ * Add Mock.assert_called()
+ * Issue25347 - Format the error message output of mock's
+ assert_has_calls method
+ * Issue #22138: Fix mock.patch behavior when patching
+ descriptors. Restore original values after patching
+ * Issue #24857: Comparing call_args to a long sequence now correctly
+ returns a boolean result instead of raising an exception
+ * Issue #23004: mock_open() now reads binary data correctly when the
+ type of read_data is bytes
+ * Add version info in the docs
+ * Update six to a version with raises_from
+ * Fix #328 - handle unicode __repr__ on Python 2.x
+ * Drop support for Python 3.2
+ * Fix typo in docs/index.txt
+ * Fix README.rst checking
+ * Be clearer about Python version compat
+ * Issue #295: use a setup_requires dependency
+ * Improve grouping of imports in tests
+ * Use six to detect python2/3 in main module
+ * Use six to detect python2/3 in test modules
+
+-------------------------------------------------------------------
python3-mock.changes: same change
Old:
----
mock-1.3.0.tar.gz
New:
----
mock-2.0.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python3-mock-doc.spec ++++++
--- /var/tmp/diff_new_pack.8hHflg/_old 2016-04-14 13:01:15.000000000 +0200
+++ /var/tmp/diff_new_pack.8hHflg/_new 2016-04-14 13:01:15.000000000 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python3-mock-doc
#
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
Name: python3-mock-doc
-Version: 1.3.0
+Version: 2.0.0
Release: 0
Url: http://www.voidspace.org.uk/python/mock/
Summary: Documentation for python3-mock
python3-mock.spec: same change
++++++ mock-1.3.0.tar.gz -> mock-2.0.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/.travis.yml new/mock-2.0.0/.travis.yml
--- old/mock-1.3.0/.travis.yml 2015-07-15 02:00:29.000000000 +0200
+++ new/mock-2.0.0/.travis.yml 2016-03-21 01:09:59.000000000 +0100
@@ -3,7 +3,6 @@
python:
- "2.6"
- "2.7"
- - "3.2"
- "3.3"
- "3.4"
- pypy
@@ -23,4 +22,4 @@
script:
- unit2
- if [ -z "$SKIP_DOCS" ]; then python setup.py build_sphinx; fi
- - rst2html.py README.rst README.html
+ - rst2html.py --strict README.rst README.html
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/AUTHORS new/mock-2.0.0/AUTHORS
--- old/mock-1.3.0/AUTHORS 2015-07-24 01:17:08.000000000 +0200
+++ new/mock-2.0.0/AUTHORS 2016-04-06 03:38:11.000000000 +0200
@@ -2,10 +2,13 @@
Antoine Pitrou
Berker Peksag
Darragh Bailey
+Frankie Robertson
+Joachim Jablon
Konrad Delong
Kumar McMillan
Kushal Das
Larry Hastings
+Michael Fladischer
Michael Foord
Michael Foord
Michael Foord
@@ -13,10 +16,13 @@
R David Murray
Rob McQueen
Robert Collins
+Senthil Kumaran
Serhiy Storchaka
Terry Jan Reedy
+Victor Stinner
convert-repo
fuzzyman
konryd
+lord63
unknown
Łukasz Langa
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/ChangeLog new/mock-2.0.0/ChangeLog
--- old/mock-1.3.0/ChangeLog 2015-07-24 01:17:08.000000000 +0200
+++ new/mock-2.0.0/ChangeLog 2016-04-06 03:38:11.000000000 +0200
@@ -1,6 +1,29 @@
CHANGES
=======
+2.0.0
+-----
+
+* Fix #338: depend on a fixed version of funcsigs
+* More 3.2 support dropping cleanup
+* Update sync point
+* Add Mock.assert_called()
+* Issue25347 - Format the error message output of mock's assert_has_calls method
+* Issue #22138: Fix mock.patch behavior when patching descriptors. Restore original values after patching
+* Issue #24857: Comparing call_args to a long sequence now correctly returns a boolean result instead of raising an exception
+* Issue #23004: mock_open() now reads binary data correctly when the type of read_data is bytes
+* Add version info in the docs
+* Update six to a version with raises_from
+* Fix #328 - handle unicode __repr__ on Python 2.x
+* Drop support for Python 3.2
+* Fix typo in docs/index.txt
+* Fix README.rst checking
+* Be clearer about Python version compat
+* Issue #295: use a setup_requires dependency
+* Improve grouping of imports in tests
+* Use six to detect python2/3 in main module
+* Use six to detect python2/3 in test modules
+
1.3.0
-----
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/NEWS new/mock-2.0.0/NEWS
--- old/mock-1.3.0/NEWS 2015-07-23 21:06:08.000000000 +0200
+++ new/mock-2.0.0/NEWS 2016-03-23 07:00:21.000000000 +0100
@@ -1,6 +1,18 @@
Library
-------
+- Issue #26323: Add Mock.assert_called() and Mock.assert_called_once()
+ methods to unittest.mock. Patch written by Amit Saha.
+
+- Issue #22138: Fix mock.patch behavior when patching descriptors. Restore
+ original values after patching. Patch contributed by Sean McCully.
+
+- Issue #24857: Comparing call_args to a long sequence now correctly returns a
+ boolean result instead of raising an exception. Patch by A Kaptur.
+
+- Issue #23004: mock_open() now reads binary data correctly when the type of
+ read_data is bytes. Initial patch by Aaron Hill.
+
- Issue #21750: mock_open.read_data can now be read from each instance, as it
could in Python 3.3.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/PKG-INFO new/mock-2.0.0/PKG-INFO
--- old/mock-1.3.0/PKG-INFO 2015-07-24 01:17:08.000000000 +0200
+++ new/mock-2.0.0/PKG-INFO 2016-04-06 03:38:11.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: mock
-Version: 1.3.0
+Version: 2.0.0
Summary: Rolling backport of unittest.mock for all Pythons
Home-page: https://github.com/testing-cabal/mock
Author: Testing Cabal
@@ -15,7 +15,7 @@
onwards.
This package contains a rolling backport of the standard library mock code
- compatible with Python 2.6 and up, and 3.2 and up.
+ compatible with Python 2.6 and up, and 3.3 and up.
Please see the standard library documentation for more details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/README.rst new/mock-2.0.0/README.rst
--- old/mock-1.3.0/README.rst 2015-07-15 02:00:52.000000000 +0200
+++ new/mock-2.0.0/README.rst 2016-03-23 23:12:30.000000000 +0100
@@ -7,7 +7,7 @@
onwards.
This package contains a rolling backport of the standard library mock code
-compatible with Python 2.6 and up, and 3.2 and up.
+compatible with Python 2.6 and up, and 3.3 and up.
Please see the standard library documentation for more details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/docs/conf.py new/mock-2.0.0/docs/conf.py
--- old/mock-1.3.0/docs/conf.py 2015-07-10 01:46:09.000000000 +0200
+++ new/mock-2.0.0/docs/conf.py 2016-03-21 01:47:08.000000000 +0100
@@ -14,6 +14,8 @@
import sys, os
sys.path.insert(0, os.path.abspath('..'))
+import mock
+
# If your extensions are in another directory, add it here. If the directory
# is relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
@@ -71,9 +73,9 @@
# other places throughout the built documents. Supplied by pbr.
#
# The short X.Y version.
-version = None
+version = mock.mock._v.brief_string()
# The full version, including alpha/beta/rc tags.
-release = None
+release = mock.__version__
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: (Set from pbr)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/docs/index.txt new/mock-2.0.0/docs/index.txt
--- old/mock-1.3.0/docs/index.txt 2015-07-23 21:51:56.000000000 +0200
+++ new/mock-2.0.0/docs/index.txt 2016-03-23 07:08:35.000000000 +0100
@@ -12,7 +12,7 @@
http://lists.idyll.org/listinfo/testing-in-python`_
:Issue tracker: `Github Issues
https://github.com/testing-cabal/mock/issues`_
-:Last sync: 3f409f756b7b8f75c4543b2c31566bd8b8dbb3dd
+:Last sync: cb6aab1248c4aec4dd578bea717854505a6fb55d
.. _Mock Homepage: https://github.com/testing-cabal/mock
.. _BSD License: http://github.com/testing-cabal/mock/blob/master/LICENSE.txt
@@ -45,7 +45,9 @@
Pythons.
The ``mock`` package contains a rolling backport of the standard library mock
-code compatible with Python 2.6 and up, and 3.2 and up.
+code compatible with Python 2.6 and up, and 3.3 and up. Python 3.2 is supported
+by mock 1.3.0 and below - with pip no longer supporting 3.2, we cannot test
+against that version anymore.
Please see the standard library documentation for usage details.
@@ -103,10 +105,10 @@
.. index:: older versions
-Older Versions
-++++++++++++++
+Older Versions of Python
+++++++++++++++++++++++++
-Version 1.0.1 is the last version compatible with Python 2.6.
+Version 1.0.1 is the last version compatible with Python < 2.6.
.. index:: maintainer notes
@@ -121,9 +123,9 @@
Committers can just push as desired: since all semantic development takes
place in cPython, the backport process is as lightweight as we can make it.
-mock is CI tested using Travis-CI on Python versions 2.6, 2.7, 3.2, 3.3, 3.4,
+mock is CI tested using Travis-CI on Python versions 2.6, 2.7, 3.3, 3.4,
3.5, nightly Python 3 builds, pypy, pypy3. Jython support is desired, if
-someone could contribute a patch to .travis.jml to support it that would be
+someone could contribute a patch to .travis.yml to support it that would be
excellent.
Releasing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/mock/mock.py new/mock-2.0.0/mock/mock.py
--- old/mock-1.3.0/mock/mock.py 2015-07-23 21:20:55.000000000 +0200
+++ new/mock-2.0.0/mock/mock.py 2016-04-06 02:42:22.000000000 +0200
@@ -74,29 +74,11 @@
import mock
-inPy3k = sys.version_info[0] == 3
-
-
try:
inspectsignature = inspect.signature
except AttributeError:
import funcsigs
inspectsignature = funcsigs.signature
- # Has funcsigs been fixed?
- try:
- class F:
- def f(a, self):
- pass
- inspectsignature(partial(F.f, None)).bind(self=10)
- except TypeError:
- def fixedbind(*args, **kwargs):
- self = args[0]
- args = args[1:]
- return self._bind(args, kwargs)
- funcsigs.Signature.bind = fixedbind
- del fixedbind
- finally:
- del F
# TODO: use six.
@@ -118,7 +100,7 @@
# Python 2.4 compatibility
BaseException = Exception
-if not inPy3k:
+if six.PY2:
# Python 2's next() can't handle a non-iterator with a __next__ method.
_next = next
def next(obj, _next=_next):
@@ -151,7 +133,7 @@
self = 'im_self'
builtin = '__builtin__'
-if inPy3k:
+if six.PY3:
self = '__self__'
builtin = 'builtins'
@@ -250,7 +232,7 @@
funcopy.__kwdefaults__ = func.__kwdefaults__
except AttributeError:
pass
- if not inPy3k:
+ if six.PY2:
funcopy.func_defaults = func.func_defaults
return
@@ -276,7 +258,7 @@
# already an instance
return getattr(obj, '__call__', None) is not None
- if inPy3k:
+ if six.PY3:
# *could* be broken by a class overriding __mro__ or __dict__ via
# a metaclass
for base in (obj,) + obj.__mro__:
@@ -410,7 +392,7 @@
ClassTypes = (type,)
-if not inPy3k:
+if six.PY2:
ClassTypes = (type, ClassType)
_allowed_names = set((
@@ -914,6 +896,24 @@
(self._mock_name or 'mock', self.call_count))
raise AssertionError(msg)
+ def assert_called(_mock_self):
+ """assert that the mock was called at least once
+ """
+ self = _mock_self
+ if self.call_count == 0:
+ msg = ("Expected '%s' to have been called." %
+ self._mock_name or 'mock')
+ raise AssertionError(msg)
+
+ def assert_called_once(_mock_self):
+ """assert that the mock was called only once.
+ """
+ self = _mock_self
+ if not self.call_count == 1:
+ msg = ("Expected '%s' to have been called once. Called %s times." %
+ (self._mock_name or 'mock', self.call_count))
+ raise AssertionError(msg)
+
def assert_called_with(_mock_self, *args, **kwargs):
"""assert that the mock was called with the specified arguments.
@@ -926,7 +926,7 @@
def _error_message(cause):
msg = self._format_mock_failure_message(args, kwargs)
- if not inPy3k and cause is not None:
+ if six.PY2 and cause is not None:
# Tack on some diagnostics for Python without __cause__
msg = '%s\n%s' % (msg, str(cause))
return msg
@@ -965,7 +965,7 @@
if expected not in all_calls:
six.raise_from(AssertionError(
'Calls not found.\nExpected: %r\n'
- 'Actual: %r' % (calls, self.mock_calls)
+ 'Actual: %r' % (_CallList(calls), self.mock_calls)
), cause)
return
@@ -1480,7 +1480,10 @@
setattr(self.target, self.attribute, self.temp_original)
else:
delattr(self.target, self.attribute)
- if not self.create and not hasattr(self.target, self.attribute):
+ if not self.create and (not hasattr(self.target, self.attribute) or
+ self.attribute in ('__doc__', '__module__',
+ '__defaults__', '__annotations__',
+ '__kwdefaults__')):
# needed for proxy objects like django settings
setattr(self.target, self.attribute, self.temp_original)
@@ -1826,12 +1829,12 @@
numerics = (
"add sub mul matmul div floordiv mod lshift rshift and xor or pow"
)
-if inPy3k:
+if six.PY3:
numerics += ' truediv'
inplace = ' '.join('i%s' % n for n in numerics.split())
right = ' '.join('r%s' % n for n in numerics.split())
extra = ''
-if inPy3k:
+if six.PY3:
extra = 'bool next '
else:
extra = 'unicode long nonzero oct hex truediv rtruediv '
@@ -2062,8 +2065,15 @@
message = '%s(%%s)' % name
formatted_args = ''
args_string = ', '.join([repr(arg) for arg in args])
+
+ def encode_item(item):
+ if six.PY2 and isinstance(item, unicode):
+ return item.encode("utf-8")
+ else:
+ return item
+
kwargs_string = ', '.join([
- '%s=%r' % (key, value) for key, value in sorted(kwargs.items())
+ '%s=%r' % (encode_item(key), value) for key, value in sorted(kwargs.items())
])
if args_string:
formatted_args = args_string
@@ -2165,8 +2175,7 @@
else:
other_args = ()
other_kwargs = value
- else:
- # len 2
+ elif len_other == 2:
# could be (name, args) or (name, kwargs) or (args, kwargs)
first, second = other
if isinstance(first, basestring):
@@ -2177,6 +2186,8 @@
other_args, other_kwargs = (), second
else:
other_args, other_kwargs = first, second
+ else:
+ return False
if self_name and other_name != self_name:
return False
@@ -2438,9 +2449,10 @@
# Helper for mock_open:
# Retrieve lines from read_data via a generator so that separate calls to
# readline, read, and readlines are properly interleaved
- data_as_list = ['{0}\n'.format(l) for l in read_data.split('\n')]
+ sep = b'\n' if isinstance(read_data, bytes) else '\n'
+ data_as_list = [l + sep for l in read_data.split(sep)]
- if data_as_list[-1] == '\n':
+ if data_as_list[-1] == sep:
# If the last line ended in a newline, the list comprehension will have an
# extra entry that's just a newline. Remove this.
data_as_list = data_as_list[:-1]
@@ -2473,7 +2485,7 @@
def _read_side_effect(*args, **kwargs):
if handle.read.return_value is not None:
return handle.read.return_value
- return ''.join(_state[0])
+ return type(read_data)().join(_state[0])
def _readline_side_effect():
if handle.readline.return_value is not None:
@@ -2486,7 +2498,7 @@
global file_spec
if file_spec is None:
# set on first use
- if inPy3k:
+ if six.PY3:
import _io
file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/mock/tests/support.py new/mock-2.0.0/mock/tests/support.py
--- old/mock-1.3.0/mock/tests/support.py 2015-07-14 04:07:05.000000000 +0200
+++ new/mock-2.0.0/mock/tests/support.py 2015-07-31 08:28:54.000000000 +0200
@@ -11,7 +11,6 @@
return hasattr(obj, '__call__')
-inPy3k = sys.version_info[0] == 3
with_available = sys.version_info[:2] >= (2, 5)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/mock/tests/testhelpers.py new/mock-2.0.0/mock/tests/testhelpers.py
--- old/mock-1.3.0/mock/tests/testhelpers.py 2015-07-14 04:07:05.000000000 +0200
+++ new/mock-2.0.0/mock/tests/testhelpers.py 2016-03-21 01:26:20.000000000 +0100
@@ -2,8 +2,8 @@
# E-mail: fuzzyman AT voidspace DOT org DOT uk
# http://www.voidspace.org.uk/python/mock/
+import six
import unittest2 as unittest
-from mock.tests.support import inPy3k
from mock import (
call, create_autospec, MagicMock,
@@ -403,7 +403,7 @@
m = create_autospec(Foo, a='3')
self.assertEqual(m.a, '3')
- @unittest.skipUnless(inPy3k, "Keyword only arguments Python 3 specific")
+ @unittest.skipUnless(six.PY3, "Keyword only arguments Python 3 specific")
def test_create_autospec_keyword_only_arguments(self):
func_def = "def foo(a, *, b=None):\n pass\n"
namespace = {}
@@ -558,7 +558,7 @@
mock.g.assert_called_once_with(3, 4)
- @unittest.skipIf(inPy3k, "No old style classes in Python 3")
+ @unittest.skipIf(six.PY3, "No old style classes in Python 3")
def test_old_style_classes(self):
class Foo:
def f(self, a, b):
@@ -745,7 +745,7 @@
mock.assert_called_with(4, 5)
- @unittest.skipIf(inPy3k, 'no old style classes in Python 3')
+ @unittest.skipIf(six.PY3, 'no old style classes in Python 3')
def test_signature_old_style_class(self):
class Foo:
def __init__(self, a, b=3):
@@ -773,7 +773,7 @@
create_autospec(Foo)
- @unittest.skipIf(inPy3k, 'no old style classes in Python 3')
+ @unittest.skipIf(six.PY3, 'no old style classes in Python 3')
def test_old_style_class_with_no_init(self):
# this used to raise an exception
# due to Foo.__init__ raising an AttributeError
@@ -928,6 +928,20 @@
self.assertEqual(str(mock.mock_calls), expected)
+ @unittest.skipIf(six.PY3, "Unicode is properly handled with Python 3")
+ def test_call_list_unicode(self):
+ # See github issue #328
+ mock = Mock()
+
+ class NonAsciiRepr(object):
+ def __repr__(self):
+ return "\xe9"
+
+ mock(**{unicode("a"): NonAsciiRepr()})
+
+ self.assertEqual(str(mock.mock_calls), "[call(a=\xe9)]")
+
+
def test_propertymock(self):
p = patch('%s.SomeClass.one' % __name__, new_callable=PropertyMock)
mock = p.start()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/mock/tests/testmagicmethods.py new/mock-2.0.0/mock/tests/testmagicmethods.py
--- old/mock-1.3.0/mock/tests/testmagicmethods.py 2015-07-14 04:07:05.000000000 +0200
+++ new/mock-2.0.0/mock/tests/testmagicmethods.py 2015-07-31 08:28:54.000000000 +0200
@@ -4,10 +4,6 @@
from __future__ import division
-import unittest2 as unittest
-
-from mock.tests.support import inPy3k
-
try:
unicode
except NameError:
@@ -18,6 +14,10 @@
import inspect
import sys
import textwrap
+
+import six
+import unittest2 as unittest
+
from mock import Mock, MagicMock
from mock.mock import _magics
@@ -86,7 +86,7 @@
self.assertEqual(str(mock), 'foo')
- @unittest.skipIf(inPy3k, "no unicode in Python 3")
+ @unittest.skipIf(six.PY3, "no unicode in Python 3")
def test_unicode(self):
mock = Mock()
self.assertEqual(unicode(mock), unicode(str(mock)))
@@ -166,7 +166,7 @@
self.assertEqual(mock.value, 16)
del mock.__truediv__
- if inPy3k:
+ if six.PY3:
def itruediv(mock):
mock /= 4
self.assertRaises(TypeError, itruediv, mock)
@@ -198,7 +198,7 @@
self.assertTrue(bool(m))
nonzero = lambda s: False
- if not inPy3k:
+ if six.PY2:
m.__nonzero__ = nonzero
else:
m.__bool__ = nonzero
@@ -216,7 +216,7 @@
self. assertTrue(mock <= 3)
self. assertTrue(mock >= 3)
- if not inPy3k:
+ if six.PY2:
# incomparable in Python 3
self.assertEqual(Mock() < 3, object() < 3)
self.assertEqual(Mock() > 3, object() > 3)
@@ -294,7 +294,7 @@
name = '__nonzero__'
other = '__bool__'
- if inPy3k:
+ if six.PY3:
name, other = other, name
getattr(mock, name).return_value = False
self.assertFalse(hasattr(mock, other))
@@ -330,7 +330,7 @@
self.assertEqual(unicode(mock), object.__str__(mock))
self.assertIsInstance(unicode(mock), unicode)
self.assertTrue(bool(mock))
- if not inPy3k:
+ if six.PY2:
self.assertEqual(oct(mock), '1')
else:
# in Python 3 oct and hex use __index__
@@ -340,7 +340,7 @@
# how to test __sizeof__ ?
- @unittest.skipIf(inPy3k, "no __cmp__ in Python 3")
+ @unittest.skipIf(six.PY3, "no __cmp__ in Python 3")
def test_non_default_magic_methods(self):
mock = MagicMock()
self.assertRaises(AttributeError, lambda: mock.__cmp__)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/mock/tests/testmock.py new/mock-2.0.0/mock/tests/testmock.py
--- old/mock-1.3.0/mock/tests/testmock.py 2015-07-23 21:20:55.000000000 +0200
+++ new/mock-2.0.0/mock/tests/testmock.py 2016-03-23 06:59:31.000000000 +0100
@@ -2,16 +2,14 @@
# E-mail: fuzzyman AT voidspace DOT org DOT uk
# http://www.voidspace.org.uk/python/mock/
-import unittest2 as unittest
-from mock.tests.support import (
- callable, inPy3k, is_instance, next
-)
-
import copy
import pickle
import sys
import tempfile
+import six
+import unittest2 as unittest
+
import mock
from mock import (
call, DEFAULT, patch, sentinel,
@@ -20,6 +18,9 @@
create_autospec
)
from mock.mock import _CallList
+from mock.tests.support import (
+ callable, is_instance, next
+)
try:
@@ -325,6 +326,9 @@
self.assertEqual(mock.call_args,
((sentinel.Arg,), {"kw": sentinel.Kwarg}))
+ # Comparing call_args to a long sequence should not raise
+ # an exception. See issue 24857.
+ self.assertFalse(mock.call_args == "a long sequence")
def test_assert_called_with(self):
mock = Mock()
@@ -663,7 +667,7 @@
copy.copy(Mock())
- @unittest.skipIf(inPy3k, "no old style classes in Python 3")
+ @unittest.skipIf(six.PY3, "no old style classes in Python 3")
def test_spec_old_style_classes(self):
class Foo:
bar = 7
@@ -677,7 +681,7 @@
self.assertRaises(AttributeError, lambda: mock.foo)
- @unittest.skipIf(inPy3k, "no old style classes in Python 3")
+ @unittest.skipIf(six.PY3, "no old style classes in Python 3")
def test_spec_set_old_style_classes(self):
class Foo:
bar = 7
@@ -1284,6 +1288,27 @@
with self.assertRaises(AssertionError):
m.hello.assert_not_called()
+ def test_assert_called(self):
+ m = Mock()
+ with self.assertRaises(AssertionError):
+ m.hello.assert_called()
+ m.hello()
+ m.hello.assert_called()
+
+ m.hello()
+ m.hello.assert_called()
+
+ def test_assert_called_once(self):
+ m = Mock()
+ with self.assertRaises(AssertionError):
+ m.hello.assert_called_once()
+ m.hello()
+ m.hello.assert_called_once()
+
+ m.hello()
+ with self.assertRaises(AssertionError):
+ m.hello.assert_called_once()
+
#Issue21256 printout of keyword args should be in deterministic order
def test_sorted_call_signature(self):
m = Mock()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/mock/tests/testpatch.py new/mock-2.0.0/mock/tests/testpatch.py
--- old/mock-1.3.0/mock/tests/testpatch.py 2015-07-14 04:07:05.000000000 +0200
+++ new/mock-2.0.0/mock/tests/testpatch.py 2016-03-23 06:54:59.000000000 +0100
@@ -5,10 +5,11 @@
import os
import sys
+import six
import unittest2 as unittest
from mock.tests import support
-from mock.tests.support import inPy3k, SomeClass, is_instance, callable
+from mock.tests.support import SomeClass, is_instance, callable
from mock import (
NonCallableMock, CallableMixin, patch, sentinel,
@@ -18,7 +19,7 @@
from mock.mock import _patch, _get_target
builtin_string = '__builtin__'
-if inPy3k:
+if six.PY3:
builtin_string = 'builtins'
unicode = str
@@ -1851,5 +1852,32 @@
self.assertEqual(stopped, ["three", "two", "one"])
+ def test_special_attrs(self):
+ def foo(x=0):
+ """TEST"""
+ return x
+ with patch.object(foo, '__defaults__', (1, )):
+ self.assertEqual(foo(), 1)
+ self.assertEqual(foo(), 0)
+
+ with patch.object(foo, '__doc__', "FUN"):
+ self.assertEqual(foo.__doc__, "FUN")
+ self.assertEqual(foo.__doc__, "TEST")
+
+ with patch.object(foo, '__module__', "testpatch2"):
+ self.assertEqual(foo.__module__, "testpatch2")
+ self.assertEqual(foo.__module__, __name__)
+
+ if hasattr(self.test_special_attrs, '__annotations__'):
+ with patch.object(foo, '__annotations__', dict([('s', 1, )])):
+ self.assertEqual(foo.__annotations__, dict([('s', 1, )]))
+ self.assertEqual(foo.__annotations__, dict())
+
+ if hasattr(self.test_special_attrs, '__kwdefaults__'):
+ foo = eval("lambda *a, x=0: x")
+ with patch.object(foo, '__kwdefaults__', dict([('x', 1, )])):
+ self.assertEqual(foo(), 1)
+ self.assertEqual(foo(), 0)
+
if __name__ == '__main__':
unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/mock/tests/testwith.py new/mock-2.0.0/mock/tests/testwith.py
--- old/mock-1.3.0/mock/tests/testwith.py 2015-07-23 21:20:55.000000000 +0200
+++ new/mock-2.0.0/mock/tests/testwith.py 2016-03-23 06:31:30.000000000 +0100
@@ -229,6 +229,34 @@
self.assertEqual(result, ['foo\n', 'bar\n', 'baz'])
+ def test_read_bytes(self):
+ mock = mock_open(read_data=b'\xc6')
+ with patch('%s.open' % __name__, mock, create=True):
+ with open('abc', 'rb') as f:
+ result = f.read()
+ self.assertEqual(result, b'\xc6')
+
+
+ def test_readline_bytes(self):
+ m = mock_open(read_data=b'abc\ndef\nghi\n')
+ with patch('%s.open' % __name__, m, create=True):
+ with open('abc', 'rb') as f:
+ line1 = f.readline()
+ line2 = f.readline()
+ line3 = f.readline()
+ self.assertEqual(line1, b'abc\n')
+ self.assertEqual(line2, b'def\n')
+ self.assertEqual(line3, b'ghi\n')
+
+
+ def test_readlines_bytes(self):
+ m = mock_open(read_data=b'abc\ndef\nghi\n')
+ with patch('%s.open' % __name__, m, create=True):
+ with open('abc', 'rb') as f:
+ result = f.readlines()
+ self.assertEqual(result, [b'abc\n', b'def\n', b'ghi\n'])
+
+
def test_mock_open_read_with_argument(self):
# At one point calling read with an argument was broken
# for mocks returned by mock_open
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/mock.egg-info/PKG-INFO new/mock-2.0.0/mock.egg-info/PKG-INFO
--- old/mock-1.3.0/mock.egg-info/PKG-INFO 2015-07-24 01:17:08.000000000 +0200
+++ new/mock-2.0.0/mock.egg-info/PKG-INFO 2016-04-06 03:38:10.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: mock
-Version: 1.3.0
+Version: 2.0.0
Summary: Rolling backport of unittest.mock for all Pythons
Home-page: https://github.com/testing-cabal/mock
Author: Testing Cabal
@@ -15,7 +15,7 @@
onwards.
This package contains a rolling backport of the standard library mock code
- compatible with Python 2.6 and up, and 3.2 and up.
+ compatible with Python 2.6 and up, and 3.3 and up.
Please see the standard library documentation for more details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/mock.egg-info/pbr.json new/mock-2.0.0/mock.egg-info/pbr.json
--- old/mock-1.3.0/mock.egg-info/pbr.json 2015-07-24 01:17:08.000000000 +0200
+++ new/mock-2.0.0/mock.egg-info/pbr.json 2016-04-06 03:38:10.000000000 +0200
@@ -1 +1 @@
-{"is_release": true, "git_version": "e34a7cb"}
\ No newline at end of file
+{"is_release": true, "git_version": "286792b"}
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/mock.egg-info/requires.txt new/mock-2.0.0/mock.egg-info/requires.txt
--- old/mock-1.3.0/mock.egg-info/requires.txt 2015-07-24 01:17:08.000000000 +0200
+++ new/mock-2.0.0/mock.egg-info/requires.txt 2016-04-06 03:38:10.000000000 +0200
@@ -1,8 +1,8 @@
pbr>=0.11
-six>=1.7
+six>=1.9
[:(python_version<"3.3")]
-funcsigs
+funcsigs>=1
[docs:(python_version<"3" or python_version>="3.3")]
sphinx
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/requirements.txt new/mock-2.0.0/requirements.txt
--- old/mock-1.3.0/requirements.txt 2015-07-10 11:17:51.000000000 +0200
+++ new/mock-2.0.0/requirements.txt 2016-04-06 02:41:15.000000000 +0200
@@ -1,6 +1,6 @@
-funcsigs;python_version<"3.3"
+funcsigs>=1;python_version<"3.3"
# For runtime needs this is correct. For setup_requires needs, 1.2.0 is needed
# but setuptools can't cope with conflicts in setup_requires, so thats
# unversioned.
pbr>=0.11
-six>=1.7
+six>=1.9
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/setup.py new/mock-2.0.0/setup.py
--- old/mock-1.3.0/setup.py 2015-07-15 02:06:46.000000000 +0200
+++ new/mock-2.0.0/setup.py 2015-07-31 08:33:00.000000000 +0200
@@ -1,18 +1,6 @@
#!/usr/bin/env python
-from distutils.version import StrictVersion
import setuptools
-import sys
-
-
-# Setuptools 17.1 is required, and setup_requires cannot upgrade setuptools
-# in-place, nor trigger the use of a newer version. Abort cleanly up-front.
-setuptools_required = StrictVersion("17.1")
-setuptools_installed = StrictVersion(setuptools.__version__)
-if setuptools_installed < setuptools_required:
- sys.stderr.write(
- "mock requires setuptools>=17.1. Aborting installation\n")
- sys.exit(1)
setuptools.setup(
- setup_requires=['pbr>=1.3'],
+ setup_requires=['pbr>=1.3', 'setuptools>=17.1'],
pbr=True)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mock-1.3.0/tools/pre-applypatch new/mock-2.0.0/tools/pre-applypatch
--- old/mock-1.3.0/tools/pre-applypatch 2015-07-15 08:37:29.000000000 +0200
+++ new/mock-2.0.0/tools/pre-applypatch 2016-03-23 23:12:53.000000000 +0100
@@ -28,7 +28,6 @@
test_version 2.6
test_version 2.7
-test_version 3.2
test_version 3.3
test_version 3.4
test_version 3.5