Accepting request 964162 from devel:languages:python:pytest

- Add patch remove-mock.patch:
  * Do not use external mock.

OBS-URL: https://build.opensuse.org/request/show/964162
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-shutil?expand=0&rev=6
This commit is contained in:
Dominique Leuenberger 2022-03-28 14:58:04 +00:00 committed by Git OBS Bridge
commit 2d1915341d
3 changed files with 64 additions and 5 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Mar 23 06:45:41 UTC 2022 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch remove-mock.patch:
* Do not use external mock.
-------------------------------------------------------------------
Fri Mar 13 12:37:42 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package python-pytest-shutil
#
# Copyright (c) 2020 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
@ -23,11 +23,11 @@ Version: 1.7.0
Release: 0
Summary: A goodie-bag of unix shell and environment tools for pytest
License: MIT
Group: Development/Languages/Python
URL: https://github.com/manahl/pytest-plugins
Source: https://files.pythonhosted.org/packages/source/p/pytest-shutil/pytest-shutil-%{version}.tar.gz
# PATCH-FIX-UPSTREAM Adapted from gh#man-group/pytest-plugins#66bf6670f3ce10106d57a77ff634a8e5c9c3a39a
Patch0: remove-mock.patch
BuildRequires: %{python_module execnet}
BuildRequires: %{python_module mock}
BuildRequires: %{python_module path.py}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools-git}
@ -40,7 +40,6 @@ BuildRequires: python-contextlib2
%endif
BuildRequires: python-rpm-macros
Requires: python-execnet
Requires: python-mock
Requires: python-path.py
Requires: python-pytest
Requires: python-six
@ -57,9 +56,10 @@ This library is a goodie-bag of Unix shell and environment management
tools for automated tests.
%prep
%setup -q -n pytest-shutil-%{version}
%autosetup -p1 -n pytest-shutil-%{version}
sed -i '/contextlib2/d' setup.py
sed -i '/path.\py/d' setup.py
sed -i '/mock/d' setup.py
%build
%python_build

53
remove-mock.patch Normal file
View File

@ -0,0 +1,53 @@
Index: pytest-shutil-1.7.0/pytest_shutil/run.py
===================================================================
--- pytest-shutil-1.7.0.orig/pytest_shutil/run.py
+++ pytest-shutil-1.7.0/pytest_shutil/run.py
@@ -11,7 +11,12 @@ import textwrap
from contextlib import closing
import subprocess
-from mock import patch
+try:
+ from unittest.mock import patch
+except ImportError:
+ # python 2
+ from mock import patch
+
import execnet
from six.moves import cPickle # @UnresolvedImport
Index: pytest-shutil-1.7.0/tests/integration/test_run_integration.py
===================================================================
--- pytest-shutil-1.7.0.orig/tests/integration/test_run_integration.py
+++ pytest-shutil-1.7.0/tests/integration/test_run_integration.py
@@ -8,7 +8,10 @@ import inspect
import textwrap
from uuid import uuid4
-import mock
+try:
+ from unittest import mock
+except ImportError:
+ import mock
from pytest_shutil import run, workspace
from pytest_shutil.env import no_cov
Index: pytest-shutil-1.7.0/tests/unit/test_run.py
===================================================================
--- pytest-shutil-1.7.0.orig/tests/unit/test_run.py
+++ pytest-shutil-1.7.0/tests/unit/test_run.py
@@ -3,7 +3,13 @@ from uuid import uuid4
from subprocess import PIPE, STDOUT
import pytest
-from mock import Mock, patch, sentinel, DEFAULT, call
+
+try:
+ from unittest.mock import Mock, patch, sentinel, DEFAULT, call
+except ImportError:
+ # python 2
+ from mock import Mock, patch, sentinel, DEFAULT, call
+
from six.moves import cPickle
from pytest_shutil import run