From 2ec7bc5d9c7fccb2097610d6b413b23eb499a244908a0c8478897e9d15d96f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Tue, 12 Feb 2019 14:32:16 +0000 Subject: [PATCH] - Add patch to fix build with pytest 4 and newer: * pytest4.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-execnet?expand=0&rev=2 --- pytest4.patch | 284 +++++++++++++++++++++++++++++++++++++++++ python-execnet.changes | 6 + python-execnet.spec | 11 +- 3 files changed, 296 insertions(+), 5 deletions(-) create mode 100644 pytest4.patch diff --git a/pytest4.patch b/pytest4.patch new file mode 100644 index 0000000..c504a03 --- /dev/null +++ b/pytest4.patch @@ -0,0 +1,284 @@ +From d62f6a3d2ea92e577664ed14f489b02ab85382f8 Mon Sep 17 00:00:00 2001 +From: Bruno Oliveira +Date: Tue, 22 Jan 2019 17:59:31 -0200 +Subject: [PATCH 1/3] Use a modern fixture instead of removed cached_setup + (pytest 4.1) + +This require us to remove the --gwscope option because we won't +be able to parametrize the fixture based on the deprecated +'pytest.config' variable + +Also remove pytest_report_header: it was displaying the removed "scope" option +and execnet's version, which seems odd and not very useful nowadays + +WIP +--- + testing/conftest.py | 29 ++++++++++------------------- + 1 file changed, 10 insertions(+), 19 deletions(-) + +Index: execnet-1.5.0/testing/conftest.py +=================================================================== +--- execnet-1.5.0.orig/testing/conftest.py ++++ execnet-1.5.0/testing/conftest.py +@@ -44,10 +44,6 @@ def pytest_addoption(parser): + '--gx', action="append", dest="gspecs", default=None, + help=("add a global test environment, XSpec-syntax. ")) + group.addoption( +- '--gwscope', action="store", dest="scope", default="session", +- type="choice", choices=["session", "function"], +- help=("set gateway setup scope, default: session.")) +- group.addoption( + '--pypy', action="store_true", dest="pypy", + help=("run some tests also against pypy")) + group.addoption( +@@ -56,13 +52,6 @@ def pytest_addoption(parser): + "page on invalid addresses")) + + +-def pytest_report_header(config): +- return [ +- "gateway test setup scope: %s" % config.getvalue("scope"), +- "execnet: %s -- %s" % (execnet.__file__, execnet.__version__), +- ] +- +- + @pytest.fixture + def specssh(request): + return getspecssh(request.config) +@@ -149,22 +138,22 @@ def anypython(request): + executable = None + py.test.skip("no %s found" % (name,)) + if "execmodel" in request.fixturenames and name != 'sys.executable': +- backend = request.getfuncargvalue("execmodel").backend ++ backend = request.getfixturevalue("execmodel").backend + if backend != "thread": + pytest.xfail( + "cannot run %r execmodel with bare %s" % (backend, name)) + return executable + + ++@pytest.fixture(scope='session') ++def group(): ++ g = execnet.Group() ++ yield g ++ g.terminate(timeout=1) ++ ++ + @pytest.fixture +-def gw(request, execmodel): +- scope = request.config.option.scope +- group = request.cached_setup( +- setup=execnet.Group, +- teardown=lambda group: group.terminate(timeout=1), +- extrakey="testgroup", +- scope=scope, +- ) ++def gw(request, execmodel, group): + try: + return group[request.param] + except KeyError: +@@ -185,7 +174,7 @@ def gw(request, execmodel): + gw.proxygw = proxygw + assert pname in group + elif request.param == "ssh": +- sshhost = request.getfuncargvalue('specssh').ssh ++ sshhost = request.getfixturevalue('specssh').ssh + # we don't use execmodel.backend here + # but you can set it when specifying the ssh spec + gw = group.makegateway("ssh=%s//id=ssh" % (sshhost,)) +@@ -193,6 +182,8 @@ def gw(request, execmodel): + group.makegateway('popen//id=proxy-transport') + gw = group.makegateway('popen//via=proxy-transport//id=proxy' + '//execmodel=%s' % execmodel.backend) ++ else: ++ assert 0, "unknown execmodel: {}".format(request.param) + return gw + + +Index: execnet-1.5.0/testing/test_serializer.py +=================================================================== +--- execnet-1.5.0.orig/testing/test_serializer.py ++++ execnet-1.5.0/testing/test_serializer.py +@@ -116,12 +116,12 @@ def py3(request): + + @pytest.fixture(params=['py2', 'py3']) + def dump(request): +- return request.getfuncargvalue(request.param).dump ++ return request.getfixturevalue(request.param).dump + + + @pytest.fixture(params=['py2', 'py3']) + def load(request): +- return request.getfuncargvalue(request.param).load ++ return request.getfixturevalue(request.param).load + + + simple_tests = [ +Index: execnet-1.5.0/testing/test_basics.py +=================================================================== +--- execnet-1.5.0.orig/testing/test_basics.py ++++ execnet-1.5.0/testing/test_basics.py +@@ -387,8 +387,10 @@ def test_remote_exec_function_with_kwarg + + def test_remote_exc__no_kwargs(makegateway): + gw = makegateway() +- pytest.raises(TypeError, gw.remote_exec, gateway_base, kwarg=1) +- pytest.raises(TypeError, gw.remote_exec, 'pass', kwarg=1) ++ with pytest.raises(TypeError): ++ gw.remote_exec(gateway_base, kwarg=1) ++ with pytest.raises(TypeError): ++ gw.remote_exec('pass', kwarg=1) + + + @skip_win_pypy +Index: execnet-1.5.0/testing/test_channel.py +=================================================================== +--- execnet-1.5.0.orig/testing/test_channel.py ++++ execnet-1.5.0/testing/test_channel.py +@@ -37,7 +37,8 @@ class TestChannelBasicBehaviour: + + def test_channel_receive_timeout(self, gw): + channel = gw.remote_exec('channel.send(channel.receive())') +- pytest.raises(channel.TimeoutError, "channel.receive(timeout=0.2)") ++ with pytest.raises(channel.TimeoutError): ++ channel.receive(timeout=0.2) + channel.send(1) + channel.receive(timeout=TESTTIMEOUT) + +@@ -263,9 +264,8 @@ class TestChannelBasicBehaviour: + """) + subchan = channel.receive() + subchan.send(1) +- excinfo = pytest.raises( +- subchan.RemoteError, +- "subchan.waitclose(TESTTIMEOUT)") ++ with pytest.raises(subchan.RemoteError) as excinfo: ++ subchan.waitclose(TESTTIMEOUT) + assert "42" in excinfo.value.formatted + channel.send(1) + channel.waitclose() +@@ -289,7 +289,8 @@ class TestChannelFile: + f = channel.makefile() + assert not f.isatty() + channel.waitclose(TESTTIMEOUT) +- pytest.raises(IOError, f.write, 'hello') ++ with pytest.raises(IOError): ++ f.write('hello') + + def test_channel_file_proxyclose(self, gw): + channel = gw.remote_exec(""" +Index: execnet-1.5.0/testing/test_gateway.py +=================================================================== +--- execnet-1.5.0.orig/testing/test_gateway.py ++++ execnet-1.5.0/testing/test_gateway.py +@@ -136,9 +136,8 @@ class TestBasicGateway: + + def test_remote_exec_no_explicit_close(self, gw): + channel = gw.remote_exec('channel.close()') +- excinfo = py.test.raises( +- channel.RemoteError, +- "channel.waitclose(TESTTIMEOUT)") ++ with pytest.raises(channel.RemoteError) as excinfo: ++ channel.waitclose(TESTTIMEOUT) + assert "explicit" in excinfo.value.formatted + + def test_remote_exec_channel_anonymous(self, gw): +@@ -216,9 +215,8 @@ class TestPopenGateway: + assert x.lower() == str(waschangedir).lower() + + def test_remoteerror_readable_traceback(self, gw): +- e = py.test.raises( +- gateway_base.RemoteError, +- 'gw.remote_exec("x y").waitclose()') ++ with pytest.raises(gateway_base.RemoteError) as e: ++ gw.remote_exec("x y").waitclose() + assert "gateway_base" in e.value.formatted + + def test_many_popen(self, makegateway): +@@ -251,9 +249,12 @@ class TestPopenGateway: + """) + remotepid = channel.receive() + py.process.kill(remotepid) +- py.test.raises(EOFError, "channel.waitclose(TESTTIMEOUT)") +- py.test.raises(IOError, channel.send, None) +- py.test.raises(EOFError, channel.receive) ++ with pytest.raises(EOFError): ++ channel.waitclose(TESTTIMEOUT) ++ with pytest.raises(IOError): ++ channel.send(None) ++ with pytest.raises(EOFError): ++ channel.receive() + + def test_receive_on_remote_sysexit(self, gw): + channel = gw.remote_exec(""" +@@ -370,8 +371,8 @@ class TestThreads: + class TestTracing: + def test_popen_filetracing(self, testdir, monkeypatch, makegateway): + tmpdir = testdir.tmpdir +- monkeypatch.setenv("TMP", tmpdir) +- monkeypatch.setenv("TEMP", tmpdir) # windows ++ monkeypatch.setenv("TMP", str(tmpdir)) ++ monkeypatch.setenv("TEMP", str(tmpdir)) # windows + monkeypatch.setenv('EXECNET_DEBUG', "1") + gw = makegateway("popen") + # hack out the debuffilename +Index: execnet-1.5.0/testing/test_multi.py +=================================================================== +--- execnet-1.5.0.orig/testing/test_multi.py ++++ execnet-1.5.0/testing/test_multi.py +@@ -175,14 +175,17 @@ class TestGroup: + group = Group() + gw = group.makegateway("popen//id=hello") + assert group["hello"] == gw +- py.test.raises((TypeError, AttributeError), "del group['hello']") +- py.test.raises((TypeError, AttributeError), "group['hello'] = 5") ++ with pytest.raises((TypeError, AttributeError)): ++ del group['hello'] ++ with pytest.raises((TypeError, AttributeError)): ++ group['hello'] = 5 + assert 'hello' in group + assert gw in group + assert len(group) == 1 + gw.exit() + assert 'hello' not in group +- py.test.raises(KeyError, "group['hello']") ++ with pytest.raises(KeyError): ++ _ = group['hello'] + + def test_default_group(self): + oldlist = list(execnet.default_group) +Index: execnet-1.5.0/testing/test_rsync.py +=================================================================== +--- execnet-1.5.0.orig/testing/test_rsync.py ++++ execnet-1.5.0/testing/test_rsync.py +@@ -90,12 +90,14 @@ class TestRSync: + rsync.add_target(gw1, dirs.dest1) + rsync.send() + assert dirs.dest1.join('hello').check() +- py.test.raises(IOError, "rsync.send()") ++ with pytest.raises(IOError): ++ rsync.send() + assert rsync.send(raises=False) is None + rsync.add_target(gw1, dirs.dest2) + rsync.send() + assert dirs.dest2.join('hello').check() +- py.test.raises(IOError, "rsync.send()") ++ with pytest.raises(IOError): ++ rsync.send() + assert rsync.send(raises=False) is None + + def test_rsync_default_reporting(self, capsys, dirs, gw1): +Index: execnet-1.5.0/testing/test_xspec.py +=================================================================== +--- execnet-1.5.0.orig/testing/test_xspec.py ++++ execnet-1.5.0/testing/test_xspec.py +@@ -23,7 +23,8 @@ class TestXSpec: + assert spec.nice is None + assert not hasattr(spec, '_xyz') + +- pytest.raises(AttributeError, "spec._hello") ++ with pytest.raises(AttributeError): ++ spec._hello() + + spec = XSpec("socket=192.168.102.2:8888//python=python2.5//nice=3") + assert spec.socket == "192.168.102.2:8888" diff --git a/python-execnet.changes b/python-execnet.changes index 7307800..5bba183 100644 --- a/python-execnet.changes +++ b/python-execnet.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Feb 12 14:25:44 UTC 2019 - Tomáš Chvátal + +- Add patch to fix build with pytest 4 and newer: + * pytest4.patch + ------------------------------------------------------------------- Wed Aug 8 11:32:26 UTC 2018 - mimi.vx@gmail.com diff --git a/python-execnet.spec b/python-execnet.spec index e00871b..e297293 100644 --- a/python-execnet.spec +++ b/python-execnet.spec @@ -1,7 +1,7 @@ # # spec file for package python-execnet # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -23,10 +23,10 @@ Release: 0 Summary: Rapid multi-Python deployment License: MIT Group: Development/Libraries/Python -URL: http://codespeak.net/execnet/ +URL: https://github.com/pytest-dev/execnet Source0: https://files.pythonhosted.org/packages/source/e/execnet/execnet-%{version}.tar.gz Patch0: fix_apipkg.patch -# test requirements +Patch1: pytest4.patch BuildRequires: %{python_module apipkg} BuildRequires: %{python_module base} BuildRequires: %{python_module pytest} @@ -51,7 +51,8 @@ API targetting the following uses: %prep %setup -q -n execnet-%{version} -%patch0 -p1 +%autopatch -p1 + sed -i "1d" execnet/script/shell.py execnet/script/socketserver.py %build