From fb00d6254d989edd0782230e18160f25e744fa0c080de5bbe703a40caaecb5e3 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Thu, 13 Jan 2022 12:32:18 +0000 Subject: [PATCH] - Add remove_double_patch.patch and remove_safe_hasattr.patch to fix https://pagure.io/python-daemon/issue/53 - Remove pytest as the test runner (apparently, the package requires python3 -munittest discovery). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-python-daemon?expand=0&rev=32 --- python-python-daemon.changes | 8 ++++++ python-python-daemon.spec | 18 ++++++++------ remove_double_patch.patch | 47 ++++++++++++++++++++++++++++++++++++ remove_safe_hasattr.patch | 15 ++++++++++++ 4 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 remove_double_patch.patch create mode 100644 remove_safe_hasattr.patch diff --git a/python-python-daemon.changes b/python-python-daemon.changes index 9918352..01929ad 100644 --- a/python-python-daemon.changes +++ b/python-python-daemon.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Jan 13 12:30:48 UTC 2022 - Matej Cepl + +- Add remove_double_patch.patch and remove_safe_hasattr.patch to + fix https://pagure.io/python-daemon/issue/53 +- Remove pytest as the test runner (apparently, the package + requires python3 -munittest discovery). + ------------------------------------------------------------------- Thu Apr 22 19:48:54 UTC 2021 - Dirk Müller diff --git a/python-python-daemon.spec b/python-python-daemon.spec index 3bb8bf7..8fcfc68 100644 --- a/python-python-daemon.spec +++ b/python-python-daemon.spec @@ -1,7 +1,7 @@ # # spec file for package python-python-daemon # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -26,10 +26,14 @@ License: Apache-2.0 AND GPL-3.0-only Group: Development/Languages/Python URL: https://pagure.io/python-daemon/ Source: https://files.pythonhosted.org/packages/source/p/python-daemon/python-daemon-%{version}.tar.gz +# PATCH-FIX-UPSTREAM remove_safe_hasattr.patch https://pagure.io/python-daemon/issue/53 mcepl@suse.com +# testtools.helpers.safe_hasattr has been removed and should never be mentioned again +Patch0: remove_safe_hasattr.patch +# PATCH-FIX-UPSTREAM remove_double_patch.patch https://pagure.io/python-daemon/issue/62 mcepl@suse.com +# some objects were mocked twice +Patch1: remove_double_patch.patch BuildRequires: %{python_module docutils} BuildRequires: %{python_module lockfile >= 0.10} -BuildRequires: %{python_module mock >= 1.3} -BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module testscenarios >= 0.4} BuildRequires: %{python_module testtools} @@ -49,7 +53,8 @@ same for every daemon program. A DaemonContext instance holds the behaviour and process environment for the program; use the instance as a context manager to enter a daemon state. %prep -%setup -q -n python-daemon-%{version} +%autosetup -p1 -n python-daemon-%{version} + sed -i '/docutils/d' setup.py %build @@ -60,10 +65,7 @@ sed -i '/docutils/d' setup.py %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -# test_returns_standard_stream_file_descriptors fails -# test_returns_expected_result fails with distutils error -# Test suite is completely broken, https://pagure.io/python-daemon/issue/53 -%python_exec -m pytest -k 'not test_returns_standard_stream_file_descriptors and not test_returns_expected_result' || /bin/true +%pyunittest discover -v %files %{python_files} %license LICENSE.ASF-2 LICENSE.GPL-3 diff --git a/remove_double_patch.patch b/remove_double_patch.patch new file mode 100644 index 0000000..1c40bf3 --- /dev/null +++ b/remove_double_patch.patch @@ -0,0 +1,47 @@ +From 0c67a3c6407fbf4483ccfc94a7a0d78cf3379296 Mon Sep 17 00:00:00 2001 +From: Miro Hrončok +Date: Sep 29 2021 10:05:27 +0000 +Subject: Remove incorrect double-patch of objects in test cases. + + +The specific test cases relying on the patches, already are decorated +to patch the specific attributes needed. We don't need a general patch +of the attributes in the test case setup. + +Signed-off-by: Ben Finney + +--- + +--- + ChangeLog | 4 ++++ + test/test_pidfile.py | 6 ------ + 2 files changed, 4 insertions(+), 6 deletions(-) + +--- a/ChangeLog ++++ b/ChangeLog +@@ -14,6 +14,10 @@ Version 2.3.0 + :Released: 2021-02-21 + :Maintainer: Ben Finney + ++* Remove incorrect double-patch of objects in test cases. ++ ++ Closes: Pagure #62. Thanks to Miro Hrončok for the report. ++ + Removed: + + * Remove support for Python versions older than Python 3. +--- a/test/test_pidfile.py ++++ b/test/test_pidfile.py +@@ -391,12 +391,6 @@ class TimeoutPIDLockFile_TestCase(scaffo + pidlockfile_scenarios = make_pidlockfile_scenarios() + self.pidlockfile_scenario = pidlockfile_scenarios['simple'] + +- for func_name in ['__init__', 'acquire']: +- func_patcher = unittest.mock.patch.object( +- lockfile.pidlockfile.PIDLockFile, func_name) +- func_patcher.start() +- self.addCleanup(func_patcher.stop) +- + self.scenario = { + 'pidfile_path': self.pidlockfile_scenario['pidfile_path'], + 'acquire_timeout': self.getUniqueInteger(), diff --git a/remove_safe_hasattr.patch b/remove_safe_hasattr.patch new file mode 100644 index 0000000..19ff367 --- /dev/null +++ b/remove_safe_hasattr.patch @@ -0,0 +1,15 @@ +--- + test/test_metadata.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/test/test_metadata.py ++++ b/test/test_metadata.py +@@ -44,7 +44,7 @@ class HasAttribute(testtools.matchers.Ma + def match(self, instance): + """ Assert the object `instance` has an attribute named `name`. """ + result = None +- if not testtools.helpers.safe_hasattr(instance, self.attribute_name): ++ if not hasattr(instance, self.attribute_name): + result = AttributeNotFoundMismatch(instance, self.attribute_name) + return result +