From 97f3a8fae4c41de451a553210a57f4dd7bb2e1446b2c5dc3c9c2d4e5e2225990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Fri, 17 Jan 2025 14:42:36 +0000 Subject: [PATCH] - do not require six - added patches fix https://github.com/man-group/pytest-plugins/commit/0018cc543229732b9c04fad909d2b7ee6167fa40 + python-pytest-shutil-no-six.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-shutil?expand=0&rev=30 --- .gitattributes | 23 ++ .gitignore | 1 + pytest-fixtures-pr171-remove-mock.patch | 72 ++++ pytest-shutil-1.7.0.tar.gz | 3 + pytest-shutil-1.8.0.tar.gz | 3 + python-pytest-shutil-no-six.patch | 437 ++++++++++++++++++++++++ python-pytest-shutil.changes | 84 +++++ python-pytest-shutil.spec | 71 ++++ stop-using-imp.patch | 36 ++ 9 files changed, 730 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 pytest-fixtures-pr171-remove-mock.patch create mode 100644 pytest-shutil-1.7.0.tar.gz create mode 100644 pytest-shutil-1.8.0.tar.gz create mode 100644 python-pytest-shutil-no-six.patch create mode 100644 python-pytest-shutil.changes create mode 100644 python-pytest-shutil.spec create mode 100644 stop-using-imp.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/pytest-fixtures-pr171-remove-mock.patch b/pytest-fixtures-pr171-remove-mock.patch new file mode 100644 index 0000000..eb4f545 --- /dev/null +++ b/pytest-fixtures-pr171-remove-mock.patch @@ -0,0 +1,72 @@ +diff --git a/pytest-shutil/pytest_shutil/run.py b/pytest-shutil/pytest_shutil/run.py +index c5b421d..7d46aea 100644 +--- a/pytest-shutil/pytest_shutil/run.py ++++ b/pytest-shutil/pytest_shutil/run.py +@@ -11,7 +11,12 @@ + 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 + +diff --git a/pytest-shutil/setup.py b/pytest-shutil/setup.py +index 4126831..3513d3e 100644 +--- a/pytest-shutil/setup.py ++++ b/pytest-shutil/setup.py +@@ -24,10 +24,11 @@ + + install_requires = ['six', + 'execnet', +- 'contextlib2', ++ 'contextlib2;python_version<"3"', + 'pytest', +- 'path.py', +- 'mock', ++ 'path; python_version >= "3.7"', ++ 'path.py; python_version < "3.7"', ++ 'mock; python_version<"3.3"', + 'termcolor' + ] + +diff --git a/pytest-shutil/tests/integration/test_run_integration.py b/pytest-shutil/tests/integration/test_run_integration.py +index d92c9da..bf20f3a 100644 +--- a/pytest-shutil/tests/integration/test_run_integration.py ++++ b/pytest-shutil/tests/integration/test_run_integration.py +@@ -8,7 +8,10 @@ + 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 +diff --git a/pytest-shutil/tests/unit/test_run.py b/pytest-shutil/tests/unit/test_run.py +index 612d20d..c520e85 100644 +--- a/pytest-shutil/tests/unit/test_run.py ++++ b/pytest-shutil/tests/unit/test_run.py +@@ -3,7 +3,13 @@ + 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 diff --git a/pytest-shutil-1.7.0.tar.gz b/pytest-shutil-1.7.0.tar.gz new file mode 100644 index 0000000..c29e5af --- /dev/null +++ b/pytest-shutil-1.7.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8165261de76e7508505c341d94c02b113dc963f274543abca74dbfabd021261 +size 23497 diff --git a/pytest-shutil-1.8.0.tar.gz b/pytest-shutil-1.8.0.tar.gz new file mode 100644 index 0000000..4846f8b --- /dev/null +++ b/pytest-shutil-1.8.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aad006ef7b6efcbace1e6bdf90ea7870c4367ab917b85fbdbac1fca1df1f48a0 +size 37608 diff --git a/python-pytest-shutil-no-six.patch b/python-pytest-shutil-no-six.patch new file mode 100644 index 0000000..ea3999c --- /dev/null +++ b/python-pytest-shutil-no-six.patch @@ -0,0 +1,437 @@ +Index: pytest-shutil-1.8.0/pytest_shutil/cmdline.py +=================================================================== +--- pytest-shutil-1.8.0.orig/pytest_shutil/cmdline.py ++++ pytest-shutil-1.8.0/pytest_shutil/cmdline.py +@@ -10,12 +10,6 @@ from contextlib import contextmanager + from tempfile import mkdtemp + + +-try: # Python 2 +- str_type = basestring +-except NameError: # Python 3 +- str_type = str +- +- + def get_log(): + return logging.getLogger(__name__) + +Index: pytest-shutil-1.8.0/pytest_shutil/run.py +=================================================================== +--- pytest-shutil-1.8.0.orig/pytest_shutil/run.py ++++ pytest-shutil-1.8.0/pytest_shutil/run.py +@@ -3,36 +3,20 @@ + """ + import sys + import os ++import pickle + import importlib.util + import logging + from functools import update_wrapper + import inspect + import textwrap +-from contextlib import closing ++from contextlib import closing, ExitStack + import subprocess +- +-try: +- from unittest.mock import patch +-except ImportError: +- # python 2 +- from mock import patch ++from unittest.mock import patch + + import execnet +-from six.moves import cPickle # @UnresolvedImport + + from . import cmdline + +-try: +- # Python 3 +- from contextlib import ExitStack +-except ImportError: +- from contextlib2 import ExitStack +- +-try: # Python 2 +- str_type = basestring +-except NameError: # Python 3 +- str_type = str +- + + log = logging.getLogger(__name__) + +@@ -68,7 +52,7 @@ def run(cmd, stdin=None, capture_stdout= + + (out, _) = p.communicate(stdin) + +- if out is not None and not isinstance(out, str_type): ++ if out is not None and not isinstance(out, str): + try: + out = out.decode('utf-8') + except: +@@ -143,22 +127,20 @@ def _make_pickleable(fn): + # return a pickleable function followed by a tuple of initial arguments + # could use partial but this is more efficient + try: +- cPickle.dumps(fn, protocol=0) +- except (TypeError, cPickle.PickleError, AttributeError): ++ pickle.dumps(fn, protocol=0) ++ except (TypeError, pickle.PickleError, AttributeError): + pass + else: + return fn, () + if inspect.ismethod(fn): + name, self_ = fn.__name__, fn.__self__ +- if self_ is None: # Python 2 unbound method +- self_ = fn.im_class + return _invoke_method, (self_, name) + elif inspect.isfunction(fn) and fn.__module__ in sys.modules: + cls, name = _find_class_from_staticmethod(fn) + if (cls, name) != (None, None): + try: +- cPickle.dumps((cls, name), protocol=0) +- except cPickle.PicklingError: ++ pickle.dumps((cls, name), protocol=0) ++ except pickle.PicklingError: + pass + else: + return _invoke_method, (cls, name) +@@ -176,9 +158,9 @@ def _run_in_subprocess_redirect_stdout(f + + + def _run_in_subprocess_remote_fn(channel): +- from six.moves import cPickle # @UnresolvedImport @Reimport # NOQA +- fn, args, kwargs = cPickle.loads(channel.receive(None)) +- channel.send(cPickle.dumps(fn(*args, **kwargs), protocol=0)) ++ import pickle ++ fn, args, kwargs = pickle.loads(channel.receive(None)) ++ channel.send(pickle.dumps(fn(*args, **kwargs), protocol=0)) + + + def run_in_subprocess(fn, python=sys.executable, cd=None, timeout=None): +@@ -204,12 +186,12 @@ def run_in_subprocess(fn, python=sys.exe + stack.callback(gw.exit) + if fix_stdout: + with closing(gw.remote_exec(_run_in_subprocess_remote_fn)) as chan: +- chan.send(cPickle.dumps((_run_in_subprocess_redirect_stdout, (fd,), {}), protocol=0)) ++ chan.send(pickle.dumps((_run_in_subprocess_redirect_stdout, (fd,), {}), protocol=0)) + chan.receive(None) + with closing(gw.remote_exec(_run_in_subprocess_remote_fn)) as chan: + payload = (pkl_fn, tuple(i for t in (preargs, args) for i in t), kwargs) +- chan.send(cPickle.dumps(payload, protocol=0)) +- return cPickle.loads(chan.receive(timeout)) ++ chan.send(pickle.dumps(payload, protocol=0)) ++ return pickle.loads(chan.receive(timeout)) + return inner if isinstance(fn, str) else update_wrapper(inner, fn) + + +Index: pytest-shutil-1.8.0/pytest_shutil/workspace.py +=================================================================== +--- pytest-shutil-1.8.0.orig/pytest_shutil/workspace.py ++++ pytest-shutil-1.8.0/pytest_shutil/workspace.py +@@ -1,6 +1,5 @@ + """ Temporary directory fixtures + """ +-from __future__ import absolute_import + import os + import tempfile + import shutil +Index: pytest-shutil-1.8.0/setup.py +=================================================================== +--- pytest-shutil-1.8.0.orig/setup.py ++++ pytest-shutil-1.8.0/setup.py +@@ -17,7 +17,7 @@ classifiers = [ + 'Programming Language :: Python :: 3.7', + ] + +-install_requires = ['six', ++install_requires = [ + 'execnet', + 'pytest', + 'termcolor' +Index: pytest-shutil-1.8.0/tests/integration/test_run_integration.py +=================================================================== +--- pytest-shutil-1.8.0.orig/tests/integration/test_run_integration.py ++++ pytest-shutil-1.8.0/tests/integration/test_run_integration.py +@@ -6,13 +6,9 @@ import pytest + import execnet + import inspect + import textwrap ++from unittest import mock + from uuid import uuid4 + +-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.8.0/tests/unit/test_run.py +=================================================================== +--- pytest-shutil-1.8.0.orig/tests/unit/test_run.py ++++ pytest-shutil-1.8.0/tests/unit/test_run.py +@@ -1,17 +1,11 @@ ++import pickle + import sys + from uuid import uuid4 + from subprocess import PIPE, STDOUT ++from unittest.mock import Mock, patch, sentinel, DEFAULT, call + + import pytest + +-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 + + ARG = str(uuid4()) +@@ -50,41 +44,41 @@ def test_run_as_main(): + + + def test_run_in_subprocess(): +- with patch.multiple('pytest_shutil.run', cPickle=DEFAULT, execnet=DEFAULT) as mocks: ++ with patch.multiple('pytest_shutil.run', pickle=DEFAULT, execnet=DEFAULT) as mocks: + fn = Mock(__name__='fn') + res = run.run_in_subprocess(fn, python='sentinel.python')(sentinel.arg, kw=sentinel.kw) + mocks['execnet'].makegateway.assert_called_once_with('popen//python=sentinel.python') + gw = mocks['execnet'].makegateway.return_value + ((remote_fn,), _) = gw.remote_exec.call_args + chan = gw.remote_exec.return_value +- mocks['cPickle'].dumps.assert_called_with((fn, (sentinel.arg,), {'kw': sentinel.kw}), protocol=0) +- chan.send.assert_called_with(mocks['cPickle'].dumps.return_value) ++ mocks['pickle'].dumps.assert_called_with((fn, (sentinel.arg,), {'kw': sentinel.kw}), protocol=0) ++ chan.send.assert_called_with(mocks['pickle'].dumps.return_value) + chan.receive.assert_has_calls([call(None) for _i in range(gw.remote_exec.call_count)]) +- mocks['cPickle'].loads.assert_called_once_with(chan.receive.return_value) +- assert res is mocks['cPickle'].loads.return_value ++ mocks['pickle'].loads.assert_called_once_with(chan.receive.return_value) ++ assert res is mocks['pickle'].loads.return_value + chan.close.assert_has_calls([call() for _i in range(gw.remote_exec.call_count)]) + gw.exit.assert_called_once_with() + +- with patch('six.moves.cPickle') as cPickle: ++ with patch('pickle.loads') as loads, patch('pickle.dumps') as dumps: + channel, fn = Mock(), Mock() +- cPickle.loads.return_value = (fn, (sentinel.arg,), {'kw': sentinel.kw}) ++ loads.return_value = (fn, (sentinel.arg,), {'kw': sentinel.kw}) + remote_fn(channel) + channel.receive.assert_called_once_with(None) +- cPickle.loads.assert_called_once_with(channel.receive.return_value) ++ loads.assert_called_once_with(channel.receive.return_value) + fn.assert_called_once_with(sentinel.arg, kw=sentinel.kw) +- cPickle.dumps.assert_called_once_with(fn.return_value, protocol=0) +- channel.send.assert_called_once_with(cPickle.dumps.return_value) ++ dumps.assert_called_once_with(fn.return_value, protocol=0) ++ channel.send.assert_called_once_with(dumps.return_value) + + + def test_run_in_runcd(): +- with patch.multiple('pytest_shutil.run', cPickle=DEFAULT, execnet=DEFAULT) as mocks: ++ with patch.multiple('pytest_shutil.run', pickle=DEFAULT, execnet=DEFAULT) as mocks: + run.run_in_subprocess(Mock(__name__='fn'), python='sentinel.python', + cd='sentinel.cd')(sentinel.arg, kw=sentinel.kw) + mocks['execnet'].makegateway.assert_called_once_with('popen//python=sentinel.python//chdir=sentinel.cd') + + + def test_run_in_runtimeout(): +- with patch.multiple('pytest_shutil.run', cPickle=DEFAULT, execnet=DEFAULT) as mocks: ++ with patch.multiple('pytest_shutil.run', pickle=DEFAULT, execnet=DEFAULT) as mocks: + run.run_in_subprocess(Mock(__name__='fn'), python='sentinel.python', + timeout=sentinel.timeout)(sentinel.arg, kw=sentinel.kw) + gw = mocks['execnet'].makegateway.return_value +@@ -100,15 +94,15 @@ def test_run_in_runpickleable_function() + with patch('pytest_shutil.run.execnet') as execnet: + gw = execnet.makegateway.return_value + chan = gw.remote_exec.return_value +- chan.receive.return_value = cPickle.dumps(sentinel.ret) ++ chan.receive.return_value = pickle.dumps(sentinel.ret) + with patch.object(run, fn.__name__, fn, create=True): + run.run_in_subprocess(fn, python='sentinel.python')(ARG, kw=KW) + ((s,), _) = chan.send.call_args +- assert cPickle.loads(s) == (fn, (ARG,), {'kw': KW}) ++ assert pickle.loads(s) == (fn, (ARG,), {'kw': KW}) + ((remote_fn,), _) = gw.remote_exec.call_args + ((chan.receive.return_value,), _) = chan.send.call_args + remote_fn(chan) +- chan.send.assert_called_with(cPickle.dumps(((ARG,), {'kw': KW}), protocol=0)) ++ chan.send.assert_called_with(pickle.dumps(((ARG,), {'kw': KW}), protocol=0)) + + + def test_run_in_runstr(): +@@ -118,14 +112,14 @@ def test_run_in_runstr(): + with patch('pytest_shutil.run.execnet') as execnet: + gw = execnet.makegateway.return_value + chan = gw.remote_exec.return_value +- chan.receive.return_value = cPickle.dumps(sentinel.ret) ++ chan.receive.return_value = pickle.dumps(sentinel.ret) + run.run_in_subprocess(source, python='sentinel.python')(ARG, kw=KW) + ((s,), _) = chan.send.call_args +- assert cPickle.loads(s) == (run._evaluate_fn_source, (source, ARG,), {'kw': KW}) ++ assert pickle.loads(s) == (run._evaluate_fn_source, (source, ARG,), {'kw': KW}) + ((remote_fn,), _) = gw.remote_exec.call_args + ((chan.receive.return_value,), _) = chan.send.call_args + remote_fn(chan) +- chan.send.assert_called_with(cPickle.dumps(((ARG,), {'kw': KW}), protocol=0)) ++ chan.send.assert_called_with(pickle.dumps(((ARG,), {'kw': KW}), protocol=0)) + + + def test_run_in_runnested_function(): +@@ -137,14 +131,14 @@ def test_run_in_runnested_function(): + with patch('pytest_shutil.run.execnet') as execnet: + gw = execnet.makegateway.return_value + chan = gw.remote_exec.return_value +- chan.receive.return_value = cPickle.dumps(sentinel.ret) ++ chan.receive.return_value = pickle.dumps(sentinel.ret) + run.run_in_subprocess(fn, python='sentinel.python')(ARG, kw=KW) + ((s,), _) = chan.send.call_args +- assert cPickle.loads(s) == (run._evaluate_fn_source, (source, ARG,), {'kw': KW}) ++ assert pickle.loads(s) == (run._evaluate_fn_source, (source, ARG,), {'kw': KW}) + ((remote_fn,), _) = gw.remote_exec.call_args + ((chan.receive.return_value,), _) = chan.send.call_args + remote_fn(chan) +- chan.send.assert_called_with(cPickle.dumps(((ARG,), {'kw': KW}), protocol=0)) ++ chan.send.assert_called_with(pickle.dumps(((ARG,), {'kw': KW}), protocol=0)) + + + @pytest.mark.xfail(sys.version_info >= (3,5), reason="python3.5 api changes") +@@ -157,23 +151,18 @@ def test_run_in_runbound_method(): + with patch('pytest_shutil.run.execnet') as execnet: + gw = execnet.makegateway.return_value + chan = gw.remote_exec.return_value +- chan.receive.return_value = cPickle.dumps(sentinel.ret) ++ chan.receive.return_value = pickle.dumps(sentinel.ret) + c = C() + with patch.object(run, C.__name__, C, create=True): + run.run_in_subprocess(c.fn, python='sentinel.python')(ARG, kw=KW) + ((s,), _) = chan.send.call_args + +- if sys.version_info < (3, 0, 0): +- # Bound methods are not pickleable in Python 2. +- assert cPickle.loads(s) == (run._invoke_method, (c, 'fn', ARG,), {'kw': KW}) +- else: +- # Bound methods are pickleable in Python 3. +- assert cPickle.loads(s) == (c.fn, (ARG,), {'kw': KW}) ++ assert pickle.loads(s) == (c.fn, (ARG,), {'kw': KW}) + + ((remote_fn,), _) = gw.remote_exec.call_args + ((chan.receive.return_value,), _) = chan.send.call_args + remote_fn(chan) +- chan.send.assert_called_with(cPickle.dumps((c, (ARG,), {'kw': KW}), protocol=0)) ++ chan.send.assert_called_with(pickle.dumps((c, (ARG,), {'kw': KW}), protocol=0)) + + + @pytest.mark.xfail(sys.version_info >= (3,5), reason="python3.5 api changes") +@@ -182,7 +171,7 @@ def test_run_in_runbound_method_on_unpic + def fn(self, *args, **kwargs): + return self, args, kwargs + with patch('pytest_shutil.run.execnet'): +- with pytest.raises(cPickle.PicklingError): ++ with pytest.raises(pickle.PicklingError): + run.run_in_subprocess(C().fn, python='sentinel.python')(ARG, kw=KW) + + +@@ -196,16 +185,16 @@ def test_run_in_rununbound_method(): + with patch('pytest_shutil.run.execnet') as execnet: + gw = execnet.makegateway.return_value + chan = gw.remote_exec.return_value +- chan.receive.return_value = cPickle.dumps(sentinel.ret) ++ chan.receive.return_value = pickle.dumps(sentinel.ret) + c = C() + with patch.object(run, C.__name__, C, create=True): + run.run_in_subprocess(C.fn, python='sentinel.python')(c, ARG, kw=KW) + ((s,), _) = chan.send.call_args +- assert cPickle.loads(s) == (run._invoke_method, (C, 'fn', c, ARG,), {'kw': KW}) ++ assert pickle.loads(s) == (run._invoke_method, (C, 'fn', c, ARG,), {'kw': KW}) + ((remote_fn,), _) = gw.remote_exec.call_args + ((chan.receive.return_value,), _) = chan.send.call_args + remote_fn(chan) +- chan.send.assert_called_with(cPickle.dumps((c, (ARG,), {'kw': KW}), protocol=0)) ++ chan.send.assert_called_with(pickle.dumps((c, (ARG,), {'kw': KW}), protocol=0)) + + + @pytest.mark.xfail(sys.version_info >= (3,5), reason="python3.5 api changes") +@@ -214,7 +203,7 @@ def test_run_in_rununbound_method_on_unp + def fn(self, *args, **kwargs): + return self, args, kwargs + with patch('pytest_shutil.run.execnet'): +- with pytest.raises(cPickle.PicklingError): ++ with pytest.raises(pickle.PicklingError): + run.run_in_subprocess(C.fn, python='sentinel.python')(C(), ARG, kw=KW) + + +@@ -229,15 +218,15 @@ def test_run_in_runstaticmethod(): + with patch('pytest_shutil.run.execnet') as execnet: + gw = execnet.makegateway.return_value + chan = gw.remote_exec.return_value +- chan.receive.return_value = cPickle.dumps(sentinel.ret) ++ chan.receive.return_value = pickle.dumps(sentinel.ret) + with patch.object(run, C.__name__, C, create=True): + run.run_in_subprocess(C.fn, python='sentinel.python')(ARG, kw=KW) + ((s,), _) = chan.send.call_args +- assert cPickle.loads(s) == (run._invoke_method, (C, 'fn', ARG,), {'kw': KW}) ++ assert pickle.loads(s) == (run._invoke_method, (C, 'fn', ARG,), {'kw': KW}) + ((remote_fn,), _) = gw.remote_exec.call_args + ((chan.receive.return_value,), _) = chan.send.call_args + remote_fn(chan) +- chan.send.assert_called_with(cPickle.dumps(((ARG,), {'kw': KW}), protocol=0)) ++ chan.send.assert_called_with(pickle.dumps(((ARG,), {'kw': KW}), protocol=0)) + + + @pytest.mark.xfail(sys.version_info >= (3,5), reason="python3.5 api changes") +@@ -255,15 +244,15 @@ def fn(*args, **kwargs): + with patch('pytest_shutil.run.execnet') as execnet: + gw = execnet.makegateway.return_value + chan = gw.remote_exec.return_value +- chan.receive.return_value = cPickle.dumps(sentinel.ret) ++ chan.receive.return_value = pickle.dumps(sentinel.ret) + with patch.object(run, C.__name__, C, create=True): + run.run_in_subprocess(C.fn, python='sentinel.python')(ARG, kw=KW) + ((s,), _) = chan.send.call_args +- assert cPickle.loads(s) == (run._evaluate_fn_source, (source, ARG,), {'kw': KW}) ++ assert pickle.loads(s) == (run._evaluate_fn_source, (source, ARG,), {'kw': KW}) + ((remote_fn,), _) = gw.remote_exec.call_args + ((chan.receive.return_value,), _) = chan.send.call_args + remote_fn(chan) +- chan.send.assert_called_with(cPickle.dumps(((ARG,), {'kw': KW}), protocol=0)) ++ chan.send.assert_called_with(pickle.dumps(((ARG,), {'kw': KW}), protocol=0)) + + + @pytest.mark.xfail(sys.version_info >= (3,5), reason="python3.5 api changes") +@@ -277,21 +266,16 @@ def test_run_in_runclassmethod(): + with patch('pytest_shutil.run.execnet') as execnet: + gw = execnet.makegateway.return_value + chan = gw.remote_exec.return_value +- chan.receive.return_value = cPickle.dumps(sentinel.ret) ++ chan.receive.return_value = pickle.dumps(sentinel.ret) + c = C() + with patch.object(run, C.__name__, C, create=True): + run.run_in_subprocess(c.fn, python='sentinel.python')(ARG, kw=KW) + ((s,), _) = chan.send.call_args +- if sys.version_info < (3, 0, 0): +- # Class methods are not pickleable in Python 2. +- assert cPickle.loads(s) == (run._invoke_method, (C, 'fn', ARG), {'kw': KW}) +- else: +- # Class methods are pickleable in Python 3. +- assert cPickle.loads(s) == (c.fn, (ARG,), {'kw': KW}) ++ assert pickle.loads(s) == (c.fn, (ARG,), {'kw': KW}) + ((remote_fn,), _) = gw.remote_exec.call_args + ((chan.receive.return_value,), _) = chan.send.call_args + remote_fn(chan) +- chan.send.assert_called_with(cPickle.dumps((C, (ARG,), {'kw': KW}), protocol=0)) ++ chan.send.assert_called_with(pickle.dumps((C, (ARG,), {'kw': KW}), protocol=0)) + + + @pytest.mark.xfail(sys.version_info >= (3,5), reason="python3.5 api changes") +@@ -301,5 +285,5 @@ def test_run_in_runclassmethod_on_unpick + def fn(cls, *args, **kwargs): + return cls, args, kwargs + with patch('pytest_shutil.run.execnet'): +- with pytest.raises(cPickle.PicklingError): ++ with pytest.raises(pickle.PicklingError): + run.run_in_subprocess(C.fn, python='sentinel.python')(ARG, kw=KW) diff --git a/python-pytest-shutil.changes b/python-pytest-shutil.changes new file mode 100644 index 0000000..ca6ca9e --- /dev/null +++ b/python-pytest-shutil.changes @@ -0,0 +1,84 @@ +------------------------------------------------------------------- +Fri Jan 17 14:21:10 UTC 2025 - pgajdos@suse.com + +- do not require six +- added patches + fix https://github.com/man-group/pytest-plugins/commit/0018cc543229732b9c04fad909d2b7ee6167fa40 + + python-pytest-shutil-no-six.patch + +------------------------------------------------------------------- +Mon Nov 4 11:05:21 UTC 2024 - Daniel Garcia + +- Remove not needed dep python-setuptools-git + +------------------------------------------------------------------- +Tue Oct 22 06:08:51 UTC 2024 - Steve Kowalik + +- Update to 1.8.0: + * Drop support for Python 2 and <3.6, removing compatibility code. + * Use stdlib unittest.mock instead of mock package. + * Removed usage of path.py and path in favour of pathlib. + * Removed contextlib2 requirement. + * Fixed forcing color through termcolor. +- Drop patches, included upstream: + * pytest-fixtures-pr171-remove-mock.patch + * stop-using-imp.patch + +------------------------------------------------------------------- +Wed Jan 24 04:48:42 UTC 2024 - Steve Kowalik + +- Add patch stop-using-imp.patch: + * Use importlib and not imp. + +------------------------------------------------------------------- +Sat Jun 10 11:50:04 UTC 2023 - ecsos + +- Add %{?sle15_python_module_pythons} + +------------------------------------------------------------------- +Mon Dec 5 11:16:10 UTC 2022 - Daniel Garcia + +- Disable test_pretty_formatter test that fails in osc build but it works when + run manually. + +------------------------------------------------------------------- +Thu Apr 21 21:51:01 UTC 2022 - Ben Greiner + +- Fixup fallout from SUSE's crusade against mock in the + pytest-fixtures family + * Replace remove-mock.patch with + pytest-fixtures-pr171-remove-mock.patch + * gh#man-group/pytest-plugins#171 + * Update build and runtime requirements + +------------------------------------------------------------------- +Wed Mar 23 06:45:41 UTC 2022 - Steve Kowalik + +- Add patch remove-mock.patch: + * Do not use external mock. + +------------------------------------------------------------------- +Fri Mar 13 12:37:42 UTC 2020 - Tomáš Chvátal + +- Build without python2 present + +------------------------------------------------------------------- +Sat Dec 28 18:31:07 UTC 2019 - Ondřej Súkup + +- fix python-path/python-path.py requires + +------------------------------------------------------------------- +Mon Jun 3 09:07:17 UTC 2019 - Tomáš Chvátal + +- Update to 1.7.0: + * Support pytest 4 + +------------------------------------------------------------------- +Fri Mar 22 07:23:42 UTC 2019 - John Vandenberg + +- Remove dependency on contextlib2 on Python 3 + +------------------------------------------------------------------- +Wed Feb 20 11:52:07 UTC 2019 - Tomáš Chvátal + +- Initial commit, neded by pytest-virtualenv diff --git a/python-pytest-shutil.spec b/python-pytest-shutil.spec new file mode 100644 index 0000000..a0b1b75 --- /dev/null +++ b/python-pytest-shutil.spec @@ -0,0 +1,71 @@ +# +# spec file for package python-pytest-shutil +# +# Copyright (c) 2025 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%{?sle15_python_module_pythons} +Name: python-pytest-shutil +Version: 1.8.0 +Release: 0 +Summary: A goodie-bag of unix shell and environment tools for pytest +License: MIT +URL: https://github.com/man-group/pytest-plugins +Source: https://files.pythonhosted.org/packages/source/p/pytest-shutil/pytest-shutil-%{version}.tar.gz +# https://github.com/man-group/pytest-plugins/commit/0018cc543229732b9c04fad909d2b7ee6167fa40 +Patch0: python-pytest-shutil-no-six.patch +BuildRequires: %{python_module execnet} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module six} +BuildRequires: %{python_module termcolor} +BuildRequires: %{python_module wheel} +BuildRequires: fdupes +BuildRequires: python-rpm-macros +Requires: python-execnet +Requires: python-pytest +Requires: python-six +Requires: python-termcolor +BuildArch: noarch + +%python_subpackages + +%description +This library is a goodie-bag of Unix shell and environment management +tools for automated tests. + +%prep +%autosetup -p1 -n pytest-shutil-%{version} + +%build +%pyproject_wheel + +%install +%pyproject_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} + +%check +# Disable test_pretty_formatter test that fails in osc build but it works when +# run manually. It should be something related to the shell and termcolor +%pytest -k "not test_pretty_formatter" + +%files %{python_files} +%doc README.md CHANGES.md +%license LICENSE +%{python_sitelib}/pytest_shutil +%{python_sitelib}/pytest_shutil-%{version}.dist-info + +%changelog diff --git a/stop-using-imp.patch b/stop-using-imp.patch new file mode 100644 index 0000000..05122ba --- /dev/null +++ b/stop-using-imp.patch @@ -0,0 +1,36 @@ +From bbb9e5c7cba84fb4665a521569d1cfcca08ee4e5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= +Date: Sat, 27 May 2023 18:05:44 +0200 +Subject: [PATCH] pytest-shutil: Replace deprecated imp module + +Replace the use of the deprecated `imp` module with `importlib.util', +as the former has been removed from Python 3.12. +--- + pytest-shutil/pytest_shutil/run.py | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/pytest-shutil/pytest_shutil/run.py b/pytest-shutil/pytest_shutil/run.py +index 7d46aea1..08a6a34c 100644 +--- a/pytest-shutil/pytest_shutil/run.py ++++ b/pytest-shutil/pytest_shutil/run.py +@@ -3,7 +3,7 @@ + """ + import sys + import os +-import imp ++import importlib.util + import logging + from functools import update_wrapper + import inspect +@@ -112,7 +112,10 @@ def run_module_as_main(module, argv=[]): + filename = os.path.splitext(filename)[0] + ".py" + + with patch("sys.argv", new=argv): +- imp.load_source('__main__', os.path.join(where, filename)) ++ spec = importlib.util.spec_from_file_location( ++ "__main__", os.path.join(where, filename)) ++ module = importlib.util.module_from_spec(spec) ++ spec.loader.exec_module(module) + + + def _evaluate_fn_source(src, *args, **kwargs):