[arch-commits] Commit in python-mock/trunk (2 files)

Eli Schwartz eschwartz at archlinux.org
Sun Aug 5 22:27:46 UTC 2018


    Date: Sunday, August 5, 2018 @ 22:27:46
  Author: eschwartz
Revision: 368430

upgpkg: python-mock 2.0.0-4

- enable tests on python2
- clean up checkdepends
- don't download pbr from PyPI during build() with --nocheck, since it is
  required for building as well

Added:
  python-mock/trunk/0001-be-able-to-run-tests-on-python2.patch
Modified:
  python-mock/trunk/PKGBUILD

--------------------------------------------+
 0001-be-able-to-run-tests-on-python2.patch |   92 +++++++++++++++++++++++++++
 PKGBUILD                                   |   44 +++++++-----
 2 files changed, 118 insertions(+), 18 deletions(-)

Added: 0001-be-able-to-run-tests-on-python2.patch
===================================================================
--- 0001-be-able-to-run-tests-on-python2.patch	                        (rev 0)
+++ 0001-be-able-to-run-tests-on-python2.patch	2018-08-05 22:27:46 UTC (rev 368430)
@@ -0,0 +1,92 @@
+From 2d7f6c41e9290ec42eae860582496f744cdc52bd Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <eschwartz at archlinux.org>
+Date: Fri, 3 Aug 2018 11:13:47 -0400
+Subject: [PATCH] be able to run tests on python2
+
+use existing six dependency to access assertRaisesRegexp as assertRaisesRegex
+---
+ mock/tests/testmagicmethods.py |  2 +-
+ mock/tests/testmock.py         | 17 ++++++++++-------
+ 2 files changed, 11 insertions(+), 8 deletions(-)
+
+diff --git a/mock/tests/testmagicmethods.py b/mock/tests/testmagicmethods.py
+index f47a202..a6c280d 100644
+--- a/mock/tests/testmagicmethods.py
++++ b/mock/tests/testmagicmethods.py
+@@ -405,7 +405,7 @@ class TestMockingMagicMethods(unittest.TestCase):
+         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
+         )
+diff --git a/mock/tests/testmock.py b/mock/tests/testmock.py
+index 66323e9..e9c5fef 100644
+--- a/mock/tests/testmock.py
++++ b/mock/tests/testmock.py
+@@ -205,7 +205,7 @@ class MockTest(unittest.TestCase):
+ 
+         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')
+@@ -501,7 +501,8 @@ class MockTest(unittest.TestCase):
+ 
+                 # this should be allowed
+                 mock.something
+-                self.assertRaisesRegex(
++                six.assertRaisesRegex(
++                    self,
+                     AttributeError,
+                     "Mock object has no attribute 'something_else'",
+                     getattr, mock, 'something_else'
+@@ -520,12 +521,14 @@ class MockTest(unittest.TestCase):
+             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__'
+@@ -591,13 +594,13 @@ class MockTest(unittest.TestCase):
+ 
+     def test_assert_called_with_message(self):
+         mock = Mock()
+-        self.assertRaisesRegex(AssertionError, 'Not called',
++        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)
+ 
+@@ -1486,7 +1489,7 @@ class MockTest(unittest.TestCase):
+         second = mopen().readline()
+         self.assertEqual('abc', first)
+         self.assertEqual('abc', second)
+- 
++
+     def test_mock_parents(self):
+         for Klass in Mock, MagicMock:
+             m = Klass()
+-- 
+2.18.0
+

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2018-08-05 21:34:28 UTC (rev 368429)
+++ PKGBUILD	2018-08-05 22:27:46 UTC (rev 368430)
@@ -5,20 +5,30 @@
 pkgbase=python-mock
 pkgname=(python2-mock python-mock)
 pkgver=2.0.0
-pkgrel=3
+pkgrel=4
 pkgdesc='Mocking and Patching Library for Testing'
 url='http://www.voidspace.org.uk/python/mock/'
-makedepends=('python2' 'python' 'python-setuptools' 'python2-setuptools')
-checkdepends=('python-nose' 'python2-nose' 'python-pbr' 'python2-pbr' 'python-six' 'python2-six' 'git')
+makedepends=('python2' 'python' 'python-pbr' 'python2-pbr')
+checkdepends=('python2-funcsigs')
 license=('BSD')
 arch=('any')
-source=("https://files.pythonhosted.org/packages/source/m/mock/mock-$pkgver.tar.gz")
-sha512sums=('a08007651b749d2843b94f5045d74c122958888290aea21930455538a854e6b04c07115e21d82edde996154bf597d7a8784a2f4213cbabc49a98dec22dd92238')
+source=("https://files.pythonhosted.org/packages/source/m/mock/mock-$pkgver.tar.gz"
+        "0001-be-able-to-run-tests-on-python2.patch")
+sha512sums=('a08007651b749d2843b94f5045d74c122958888290aea21930455538a854e6b04c07115e21d82edde996154bf597d7a8784a2f4213cbabc49a98dec22dd92238'
+            '8da4aa25e7f35482369c6e69b4c430b0a506203b5629771cf63932f98d9c4167ed0a08c541baf4993749c24b28cacf0bb26328d34445e7e39448edb89e329f12')
 
-build() {
+prepare() {
+  cd "$srcdir/mock-$pkgver"
+  # self.assertRaisesRegex() is self.assertRaisesRegexp() in Python 2.7
+  patch -p1 -i ../0001-be-able-to-run-tests-on-python2.patch
+  # use unittest instead of unittest2 as they are the same on recent python*
+  sed -i 's/unittest2/unittest/g' mock/tests/*.py
+
   cd "$srcdir"
   cp -rf "mock-$pkgver" "mock2-$pkgver"
+}
 
+build() {
   cd "$srcdir/mock-$pkgver"
   python3 setup.py build
 
@@ -26,6 +36,16 @@
   python2 setup.py build
 }
 
+check() {
+  cd "$srcdir/mock-$pkgver"
+  echo 'python tests'
+  python -m unittest discover
+
+  cd "$srcdir/mock2-$pkgver"
+  echo 'python2 tests'
+  python2 -m unittest discover
+}
+
 package_python-mock() {
 depends=('python' 'python-six' 'python-pbr')
   cd "$srcdir/mock-$pkgver"
@@ -39,15 +59,3 @@
   python2 setup.py install --optimize=1 --root="$pkgdir"
   install -Dm644 LICENSE.txt "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
 }
-
-check() {
-  cd "$srcdir/mock2-$pkgver/"
-  sed -i 's/unittest2/unittest/g'  mock/tests/*.py
-
-  echo 'python tests'
-  python -m unittest discover
-  
-  # Does not run because of self.assertRaisesRegex() usage in unitests, which is self.assertRaisesRegexp() in Python 2.7
-  echo 'python2 tests'
-  #python2 -m unittest discover
-}



More information about the arch-commits mailing list