summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-block/bmap-tools/bmap-tools-3.6-r1.ebuild (renamed from sys-block/bmap-tools/bmap-tools-3.6.ebuild)27
-rw-r--r--sys-block/bmap-tools/files/bmap-tools-3.6-mock-import-pattern.patch94
-rw-r--r--sys-block/bmap-tools/files/bmap-tools-3.6-unittest-mock.patch44
3 files changed, 154 insertions, 11 deletions
diff --git a/sys-block/bmap-tools/bmap-tools-3.6.ebuild b/sys-block/bmap-tools/bmap-tools-3.6-r1.ebuild
index 5ba041f67df6..5a474a6f2428 100644
--- a/sys-block/bmap-tools/bmap-tools-3.6.ebuild
+++ b/sys-block/bmap-tools/bmap-tools-3.6-r1.ebuild
@@ -1,8 +1,9 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-EAPI=7
-PYTHON_COMPAT=( python3_{9..10} )
+EAPI=8
+PYTHON_COMPAT=( python3_{9..11} )
+DISTUTILS_USE_PEP517=setuptools
inherit distutils-r1
@@ -24,8 +25,7 @@ IUSE="test"
BDEPEND="${PYTHON_DEPS}
dev-python/setuptools[${PYTHON_USEDEP}]
- test? ( dev-python/nose[${PYTHON_USEDEP}]
- dev-python/six[${PYTHON_USEDEP}] )
+ test? ( dev-python/six[${PYTHON_USEDEP}] )
"
RDEPEND="
@@ -41,14 +41,19 @@ RDEPEND="
DOCS=( "${S}/docs/README" )
+PATCHES=(
+ "${FILESDIR}"/${P}-unittest-mock.patch
+ "${FILESDIR}"/${P}-mock-import-pattern.patch
+)
+
# tests are hanging using default below
RESTRICT="!test? ( test )"
-distutils_enable_tests nose
-
-python_test() {
+EPYTEST_DESELECT=(
# remaining tests involve way too much file I/O
- nosetests -sx --verbosity=3 --detailed-errors \
- tests/test_bmap_helpers.py \
- tests/test_compat.py || die "Tests fail with ${EPYTHON}"
-}
+ tests/test_api_base.py # too many open files
+ tests/test_bmap_helpers.py::TestBmapHelpers::test_get_file_system_type_symlink # depends on backports.tempfile
+ tests/test_bmap_helpers.py::TestBmapHelpers::test_is_zfs_configuration_compatible_unreadable_file # fails
+)
+
+distutils_enable_tests pytest
diff --git a/sys-block/bmap-tools/files/bmap-tools-3.6-mock-import-pattern.patch b/sys-block/bmap-tools/files/bmap-tools-3.6-mock-import-pattern.patch
new file mode 100644
index 000000000000..cb27ff08ac36
--- /dev/null
+++ b/sys-block/bmap-tools/files/bmap-tools-3.6-mock-import-pattern.patch
@@ -0,0 +1,94 @@
+Upstream commit: https://github.com/intel/bmap-tools/commit/47908b5389d1f3de9306c0030856b3d3180ade86
+Related Gentoo bug: https://bugs.gentoo.org/833258
+
+I had to change the first hunk a bit to also remove `backports`
+
+From 47908b5389d1f3de9306c0030856b3d3180ade86 Mon Sep 17 00:00:00 2001
+From: Simon McVittie <smcv@debian.org>
+Date: Thu, 28 Oct 2021 12:23:30 +0100
+Subject: [PATCH] tests: Fix import pattern for mock objects
+
+The legacy mock module contains a mock.mock submodule, but unittest.mock
+does not contain a redundant unittest.mock.mock. This bug was masked by
+the transparent fallback to the legacy mock module.
+
+The actual test only uses mock.patch(), so we can simplify by just
+importing the one member that we need.
+
+Fixes: a1ca1172 "tests: Use unittest.mock from Python standard library if possible"
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ tests/test_bmap_helpers.py | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/tests/test_bmap_helpers.py b/tests/test_bmap_helpers.py
+index 56b079e..36c4557 100644
+--- a/tests/test_bmap_helpers.py
++++ b/tests/test_bmap_helpers.py
+@@ -22,10 +22,9 @@
+ import sys
+ import tempfile
+ try:
+- from unittest.mock import patch, mock
++ from unittest.mock import patch
+ except ImportError: # for Python < 3.3
+- from mock import patch, mock
+-from backports import tempfile as btempfile
++ from mock import patch
+ from bmaptools import BmapHelpers
+
+
+@@ -76,7 +76,7 @@ def test_is_zfs_configuration_compatible_enabled(self):
+ delete=True, dir=".", suffix=".txt") as fobj:
+ fobj.write("1")
+ fobj.flush()
+- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
++ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
+ with mockobj:
+ self.assertTrue(BmapHelpers.is_zfs_configuration_compatible())
+
+@@ -88,7 +88,7 @@ def test_is_zfs_configuration_compatible_disabled(self):
+ delete=True, dir=".", suffix=".txt") as fobj:
+ fobj.write("0")
+ fobj.flush()
+- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
++ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
+ with mockobj:
+ self.assertFalse(BmapHelpers.is_zfs_configuration_compatible())
+
+@@ -97,7 +97,7 @@ def test_is_zfs_configuration_compatible_invalid_read_value(self):
+
+ with tempfile.NamedTemporaryFile("a", prefix="testfile_",
+ delete=True, dir=".", suffix=".txt") as fobj:
+- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
++ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
+ with self.assertRaises(BmapHelpers.Error):
+ with mockobj:
+ BmapHelpers.is_zfs_configuration_compatible()
+@@ -116,7 +116,7 @@ def test_is_zfs_configuration_compatible_notinstalled(self):
+
+ directory = os.path.dirname(__file__)
+ filepath = os.path.join(directory, "BmapHelpers/file/does/not/exist")
+- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", filepath)
++ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", filepath)
+ with mockobj:
+ self.assertFalse(BmapHelpers.is_zfs_configuration_compatible())
+
+@@ -128,7 +128,7 @@ def test_is_compatible_file_system_zfs_valid(self, mock_get_fs_type): #pylint: d
+ delete=True, dir=".", suffix=".img") as fobj:
+ fobj.write("1")
+ fobj.flush()
+- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
++ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
+ with mockobj:
+ self.assertTrue(BmapHelpers.is_compatible_file_system(fobj.name))
+
+@@ -140,7 +140,7 @@ def test_is_compatible_file_system_zfs_invalid(self, mock_get_fs_type): #pylint:
+ delete=True, dir=".", suffix=".img") as fobj:
+ fobj.write("0")
+ fobj.flush()
+- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
++ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
+ with mockobj:
+ self.assertFalse(BmapHelpers.is_compatible_file_system(fobj.name))
+
diff --git a/sys-block/bmap-tools/files/bmap-tools-3.6-unittest-mock.patch b/sys-block/bmap-tools/files/bmap-tools-3.6-unittest-mock.patch
new file mode 100644
index 000000000000..9c509f227a1f
--- /dev/null
+++ b/sys-block/bmap-tools/files/bmap-tools-3.6-unittest-mock.patch
@@ -0,0 +1,44 @@
+Upstream commit: https://github.com/intel/bmap-tools/commit/a1ca1172f259f32ff9eb0469567be1a9085cca88
+Related Gentoo bug: https://bugs.gentoo.org/833258
+
+From a1ca1172f259f32ff9eb0469567be1a9085cca88 Mon Sep 17 00:00:00 2001
+From: Simon McVittie <smcv@debian.org>
+Date: Thu, 28 Oct 2021 11:03:09 +0100
+Subject: [PATCH] tests: Use unittest.mock from Python standard library if
+ possible
+
+This avoids an unnecessary external dependency when using Python >= 3.3.
+
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ requirements-test.txt | 2 +-
+ tests/test_bmap_helpers.py | 5 ++++-
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/requirements-test.txt b/requirements-test.txt
+index 1cc6bbb..cea340a 100644
+--- a/requirements-test.txt
++++ b/requirements-test.txt
+@@ -1,4 +1,4 @@
+ six
+ nose
+ backports.tempfile
+-mock
+\ No newline at end of file
++mock ; python_version < '3.3'
+diff --git a/tests/test_bmap_helpers.py b/tests/test_bmap_helpers.py
+index 1617957..47b3862 100644
+--- a/tests/test_bmap_helpers.py
++++ b/tests/test_bmap_helpers.py
+@@ -21,7 +21,10 @@
+ import os
+ import sys
+ import tempfile
+-from mock import patch, mock
++try:
++ from unittest.mock import patch, mock
++except ImportError: # for Python < 3.3
++ from mock import patch, mock
+ from backports import tempfile as btempfile
+ from bmaptools import BmapHelpers
+