[Python-modules-commits] r33506 - in packages/python-mock/trunk/debian (3 files)

fladi at users.alioth.debian.org fladi at users.alioth.debian.org
Tue Jul 28 15:31:17 UTC 2015


    Date: Tuesday, July 28, 2015 @ 15:31:16
  Author: fladi
Revision: 33506

Add six.patch to provide python2 and 3 compatibility for tests.

Added:
  packages/python-mock/trunk/debian/patches/
  packages/python-mock/trunk/debian/patches/series
  packages/python-mock/trunk/debian/patches/six.patch

Added: packages/python-mock/trunk/debian/patches/series
===================================================================
--- packages/python-mock/trunk/debian/patches/series	                        (rev 0)
+++ packages/python-mock/trunk/debian/patches/series	2015-07-28 15:31:16 UTC (rev 33506)
@@ -0,0 +1 @@
+six.patch

Added: packages/python-mock/trunk/debian/patches/six.patch
===================================================================
--- packages/python-mock/trunk/debian/patches/six.patch	                        (rev 0)
+++ packages/python-mock/trunk/debian/patches/six.patch	2015-07-28 15:31:16 UTC (rev 33506)
@@ -0,0 +1,351 @@
+Description: Use six to make tests useable in both python2 and 3
+ Upstream uses methods from the unittest framework (assertRaisesRegex[p]) that haven been renamed
+ between python2 and 3. six already provides a convenience wrapper for this. The
+ internal detection of python2/3 has been replaced with the one from six.
+ The unittest framework is now imported using its python2.7 name instead of
+ importing unittest2 as unittest.
+Author: Michael Fladischer <fladi at debian.org>
+Last-Update: 2015-07-28
+Forwarded: no
+
+Index: python-mock/mock/tests/testmock.py
+===================================================================
+--- python-mock.orig/mock/tests/testmock.py	2015-07-23 21:20:55.000000000 +0200
++++ python-mock/mock/tests/testmock.py	2015-07-28 17:07:22.857335343 +0200
+@@ -2,15 +2,16 @@
+ # 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
++    callable, is_instance, next
+ )
+ 
++import six
+ import copy
+ import pickle
+ import sys
+ import tempfile
++import unittest
+ 
+ import mock
+ from mock import (
+@@ -206,7 +207,7 @@
+ 
+         mock = create_autospec(f)
+         mock.side_effect = ValueError('Bazinga!')
+-        self.assertRaisesRegex(ValueError, 'Bazinga!', mock)
++        six.assertRaisesRegex(self, ValueError, 'Bazinga!', mock)
+ 
+     @unittest.skipUnless('java' in sys.platform,
+                           'This test only applies to Jython')
+@@ -499,7 +500,8 @@
+ 
+                 # this should be allowed
+                 mock.something
+-                self.assertRaisesRegex(
++                six.assertRaisesRegex(
++                    self,
+                     AttributeError,
+                     "Mock object has no attribute 'something_else'",
+                     getattr, mock, 'something_else'
+@@ -518,12 +520,14 @@
+             mock.x
+             mock.y
+             mock.__something__
+-            self.assertRaisesRegex(
++            six.assertRaisesRegex(
++                self,
+                 AttributeError,
+                 "Mock object has no attribute 'z'",
+                 getattr, mock, 'z'
+             )
+-            self.assertRaisesRegex(
++            six.assertRaisesRegex(
++                self,
+                 AttributeError,
+                 "Mock object has no attribute '__foobar__'",
+                 getattr, mock, '__foobar__'
+@@ -589,13 +593,13 @@
+ 
+     def test_assert_called_with_message(self):
+         mock = Mock()
+-        self.assertRaisesRegex(AssertionError, 'Not called',
+-                                mock.assert_called_with)
++        six.assertRaisesRegex(self, AssertionError, 'Not called',
++                               mock.assert_called_with)
+ 
+ 
+     def test_assert_called_once_with_message(self):
+         mock = Mock(name='geoffrey')
+-        self.assertRaisesRegex(AssertionError,
++        six.assertRaisesRegex(self, AssertionError,
+                      r"Expected 'geoffrey' to be called once\.",
+                      mock.assert_called_once_with)
+ 
+@@ -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
+@@ -1463,7 +1467,7 @@
+         second = mopen().readline()
+         self.assertEqual('abc', first)
+         self.assertEqual('abc', second)
+- 
++
+     def test_mock_parents(self):
+         for Klass in Mock, MagicMock:
+             m = Klass()
+Index: python-mock/mock/tests/testmagicmethods.py
+===================================================================
+--- python-mock.orig/mock/tests/testmagicmethods.py	2015-07-14 04:07:05.000000000 +0200
++++ python-mock/mock/tests/testmagicmethods.py	2015-07-28 17:09:02.415394727 +0200
+@@ -4,10 +4,6 @@
+ 
+ from __future__ import division
+ 
+-import unittest2 as unittest
+-
+-from mock.tests.support import inPy3k
+-
+ try:
+     unicode
+ except NameError:
+@@ -15,14 +11,16 @@
+     unicode = str
+     long = int
+ 
++import six
+ import inspect
+ import sys
+ import textwrap
++import unittest
++
+ from mock import Mock, MagicMock
+ from mock.mock import _magics
+ 
+ 
+-
+ class TestMockingMagicMethods(unittest.TestCase):
+ 
+     def test_deleting_magic_methods(self):
+@@ -86,7 +84,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 +164,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 +196,7 @@
+         self.assertTrue(bool(m))
+ 
+         nonzero = lambda s: False
+-        if not inPy3k:
++        if six.PY2:
+             m.__nonzero__ = nonzero
+         else:
+             m.__bool__ = nonzero
+@@ -216,7 +214,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 +292,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 +328,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 +338,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__)
+@@ -405,7 +403,7 @@
+         mock = MagicMock()
+         def set_setattr():
+             mock.__setattr__ = lambda self, name: None
+-        self.assertRaisesRegex(AttributeError,
++        six.assertRaisesRegex(self, AttributeError,
+             "Attempting to set unsupported magic method '__setattr__'.",
+             set_setattr
+         )
+Index: python-mock/mock/tests/support.py
+===================================================================
+--- python-mock.orig/mock/tests/support.py	2015-07-14 04:07:05.000000000 +0200
++++ python-mock/mock/tests/support.py	2015-07-28 17:10:24.101083124 +0200
+@@ -1,7 +1,7 @@
+ import sys
++import unittest
+ 
+ info = sys.version_info
+-import unittest2
+ 
+ 
+ try:
+Index: python-mock/mock/tests/testcallable.py
+===================================================================
+--- python-mock.orig/mock/tests/testcallable.py	2015-07-14 04:07:05.000000000 +0200
++++ python-mock/mock/tests/testcallable.py	2015-07-28 17:12:22.763533785 +0200
+@@ -2,7 +2,8 @@
+ # E-mail: fuzzyman AT voidspace DOT org DOT uk
+ # http://www.voidspace.org.uk/python/mock/
+ 
+-import unittest2 as unittest
++import unittest
++
+ from mock.tests.support import is_instance, X, SomeClass
+ 
+ from mock import (
+Index: python-mock/mock/tests/testhelpers.py
+===================================================================
+--- python-mock.orig/mock/tests/testhelpers.py	2015-07-14 04:07:05.000000000 +0200
++++ python-mock/mock/tests/testhelpers.py	2015-07-28 17:12:14.159356169 +0200
+@@ -2,8 +2,9 @@
+ # 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 inPy3k
++import six
++
++import unittest
+ 
+ from mock import (
+     call, create_autospec, MagicMock,
+@@ -403,7 +404,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 +559,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 +746,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 +774,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
+Index: python-mock/mock/tests/testpatch.py
+===================================================================
+--- python-mock.orig/mock/tests/testpatch.py	2015-07-14 04:07:05.000000000 +0200
++++ python-mock/mock/tests/testpatch.py	2015-07-28 17:11:46.126777402 +0200
+@@ -4,11 +4,11 @@
+ 
+ import os
+ import sys
+-
+-import unittest2 as unittest
++import six
++import 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 +18,7 @@
+ from mock.mock import _patch, _get_target
+ 
+ builtin_string = '__builtin__'
+-if inPy3k:
++if six.PY3:
+     builtin_string = 'builtins'
+     unicode = str
+ 
+Index: python-mock/mock/tests/testsentinel.py
+===================================================================
+--- python-mock.orig/mock/tests/testsentinel.py	2015-07-14 04:07:05.000000000 +0200
++++ python-mock/mock/tests/testsentinel.py	2015-07-28 17:10:42.037453706 +0200
+@@ -2,7 +2,7 @@
+ # E-mail: fuzzyman AT voidspace DOT org DOT uk
+ # http://www.voidspace.org.uk/python/mock/
+ 
+-import unittest2 as unittest
++import unittest
+ 
+ from mock import sentinel, DEFAULT
+ 
+Index: python-mock/mock/tests/testwith.py
+===================================================================
+--- python-mock.orig/mock/tests/testwith.py	2015-07-23 21:20:55.000000000 +0200
++++ python-mock/mock/tests/testwith.py	2015-07-28 17:09:53.028441006 +0200
+@@ -4,7 +4,7 @@
+ 
+ from warnings import catch_warnings
+ 
+-import unittest2 as unittest
++import unittest
+ 
+ from mock.tests.support import is_instance
+ from mock import MagicMock, Mock, patch, sentinel, mock_open, call




More information about the Python-modules-commits mailing list