Skip to content

Commit dbb5449

Browse files
authored
Merge pull request #160 from nicoddemus/fix-ci
Fix CI for pytest 7.2+
2 parents 2603fff + d2ae103 commit dbb5449

File tree

9 files changed

+31
-34
lines changed

9 files changed

+31
-34
lines changed

testing/conftest.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def pytest_runtest_setup(item):
2424
getspecssh(item.config) # will skip if no gx given
2525
yield
2626
if "pypy" in item.keywords and not item.config.option.pypy:
27-
py.test.skip("pypy tests skipped, use --pypy to run them.")
27+
pytest.skip("pypy tests skipped, use --pypy to run them.")
2828

2929

3030
@pytest.fixture
@@ -74,28 +74,26 @@ def specsocket(request):
7474
return getsocketspec(request.config)
7575

7676

77-
def getgspecs(config=None):
78-
if config is None:
79-
config = py.test.config
77+
def getgspecs(config):
8078
return map(execnet.XSpec, config.getvalueorskip("gspecs"))
8179

8280

83-
def getspecssh(config=None):
81+
def getspecssh(config):
8482
xspecs = getgspecs(config)
8583
for spec in xspecs:
8684
if spec.ssh:
8785
if not py.path.local.sysfind("ssh"):
88-
py.test.skip("command not found: ssh")
86+
pytest.skip("command not found: ssh")
8987
return spec
90-
py.test.skip("need '--gx ssh=...'")
88+
pytest.skip("need '--gx ssh=...'")
9189

9290

93-
def getsocketspec(config=None):
91+
def getsocketspec(config):
9492
xspecs = getgspecs(config)
9593
for spec in xspecs:
9694
if spec.socket:
9795
return spec
98-
py.test.skip("need '--gx socket=...'")
96+
pytest.skip("need '--gx socket=...'")
9997

10098

10199
def pytest_generate_tests(metafunc):
@@ -149,7 +147,7 @@ def anypython(request):
149147
if executable.check():
150148
return executable
151149
executable = None
152-
py.test.skip("no {} found".format(name))
150+
pytest.skip("no {} found".format(name))
153151
if "execmodel" in request.fixturenames and name != "sys.executable":
154152
backend = request.getfixturevalue("execmodel").backend
155153
if backend != "thread":

testing/test_channel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
"""
55
import time
66

7-
import py
87
import pytest
98
from test_gateway import _find_version
109

10+
1111
needs_early_gc = pytest.mark.skipif("not hasattr(sys, 'getrefcount')")
1212
needs_osdup = pytest.mark.skipif("not hasattr(os, 'dup')")
13-
queue = py.builtin._tryimport("queue", "Queue")
1413
TESTTIMEOUT = 10.0 # seconds
1514

1615

testing/test_gateway.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from test_serializer import _find_version
1717

1818
TESTTIMEOUT = 10.0 # seconds
19-
needs_osdup = py.test.mark.skipif("not hasattr(os, 'dup')")
19+
needs_osdup = pytest.mark.skipif("not hasattr(os, 'dup')")
2020

2121

2222
flakytest = pytest.mark.xfail(
@@ -36,10 +36,10 @@ def test_deprecation(recwarn, monkeypatch):
3636
execnet.PopenGateway().exit()
3737
assert recwarn.pop(DeprecationWarning)
3838
monkeypatch.setattr(socket, "socket", fails)
39-
py.test.raises(Exception, execnet.SocketGateway, "localhost", 8811)
39+
pytest.raises(Exception, execnet.SocketGateway, "localhost", 8811)
4040
assert recwarn.pop(DeprecationWarning)
4141
monkeypatch.setattr(subprocess, "Popen", fails)
42-
py.test.raises(Exception, execnet.SshGateway, "not-existing")
42+
pytest.raises(Exception, execnet.SshGateway, "not-existing")
4343
assert recwarn.pop(DeprecationWarning)
4444

4545

@@ -213,7 +213,7 @@ def test_remote_exec_waitclose_noarg(self, gw):
213213
def test_remote_exec_error_after_close(self, gw):
214214
channel = gw.remote_exec("pass")
215215
channel.waitclose(TESTTIMEOUT)
216-
py.test.raises(IOError, channel.send, 0)
216+
pytest.raises(IOError, channel.send, 0)
217217

218218
def test_remote_exec_no_explicit_close(self, gw):
219219
channel = gw.remote_exec("channel.close()")
@@ -353,7 +353,7 @@ def test_receive_on_remote_sysexit(self, gw):
353353
raise SystemExit()
354354
"""
355355
)
356-
py.test.raises(channel.RemoteError, channel.receive)
356+
pytest.raises(channel.RemoteError, channel.receive)
357357

358358
def test_dont_write_bytecode(self, makegateway):
359359
check_sys_dont_write_bytecode = """
@@ -371,9 +371,9 @@ def test_dont_write_bytecode(self, makegateway):
371371
assert ret
372372

373373

374-
@py.test.mark.skipif("config.option.broken_isp")
374+
@pytest.mark.skipif("config.option.broken_isp")
375375
def test_socket_gw_host_not_found(gw, makegateway):
376-
py.test.raises(execnet.HostNotFound, lambda: makegateway("socket=qwepoipqwe:9000"))
376+
pytest.raises(execnet.HostNotFound, lambda: makegateway("socket=qwepoipqwe:9000"))
377377

378378

379379
class TestSshPopenGateway:
@@ -384,7 +384,7 @@ def test_sshconfig_config_parsing(self, monkeypatch, makegateway):
384384
monkeypatch.setattr(
385385
gateway_io, "Popen2IOMaster", lambda *args, **kwargs: l.append(args[0])
386386
)
387-
py.test.raises(AttributeError, lambda: makegateway("ssh=xyz//ssh_config=qwe"))
387+
pytest.raises(AttributeError, lambda: makegateway("ssh=xyz//ssh_config=qwe"))
388388

389389
assert len(l) == 1
390390
popen_args = l[0]
@@ -395,7 +395,7 @@ def test_sshaddress(self, gw, specssh):
395395
assert gw.remoteaddress == specssh.ssh
396396

397397
def test_host_not_found(self, gw, makegateway):
398-
py.test.raises(
398+
pytest.raises(
399399
execnet.HostNotFound, lambda: makegateway("ssh=nowhere.codespeak.net")
400400
)
401401

@@ -477,7 +477,7 @@ def test_popen_filetracing(self, testdir, monkeypatch, makegateway):
477477
if worker_line in line:
478478
break
479479
else:
480-
py.test.fail("did not find {!r} in tracefile".format(worker_line))
480+
pytest.fail("did not find {!r} in tracefile".format(worker_line))
481481
gw.exit()
482482

483483
@skip_win_pypy
@@ -498,7 +498,7 @@ def test_no_tracing_by_default(self):
498498

499499

500500
class TestStringCoerce:
501-
@py.test.mark.skipif('sys.version>="3.0"')
501+
@pytest.mark.skipif('sys.version>="3.0"')
502502
def test_2to3(self, makegateway):
503503
python = _find_version("3")
504504
gw = makegateway("popen//python=%s" % python)
@@ -515,7 +515,7 @@ def test_2to3(self, makegateway):
515515
assert isinstance(res, str)
516516
gw.exit()
517517

518-
@py.test.mark.skipif('sys.version<"3.0"')
518+
@pytest.mark.skipif('sys.version<"3.0"')
519519
def test_3to2(self, makegateway):
520520
python = _find_version("2")
521521
gw = makegateway("popen//python=%s" % python)

testing/test_multi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def join(self):
141141
def test_group_default_spec(self):
142142
group = Group()
143143
group.defaultspec = "not-existing-type"
144-
py.test.raises(ValueError, group.makegateway)
144+
pytest.raises(ValueError, group.makegateway)
145145

146146
def test_group_PopenGateway(self):
147147
group = Group()
@@ -176,7 +176,7 @@ def test_group_id_allocation(self):
176176
assert gw.id == "hello"
177177
gw = group.makegateway(specs[0])
178178
assert gw.id == "gw0"
179-
# py.test.raises(ValueError,
179+
# pytest.raises(ValueError,
180180
# group.allocate_id, XSpec("popen//id=hello"))
181181
group.terminate()
182182

testing/test_rsync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def test_rsync_non_verbose(self, capsys, dirs, gw1):
123123
assert not out
124124
assert not err
125125

126-
@py.test.mark.skipif("sys.platform == 'win32' or getattr(os, '_name', '') == 'nt'")
126+
@pytest.mark.skipif("sys.platform == 'win32' or getattr(os, '_name', '') == 'nt'")
127127
def test_permissions(self, dirs, gw1, gw2):
128128
source = dirs.source
129129
dest = dirs.dest1
@@ -230,7 +230,7 @@ def filter(self, x):
230230
assert len(dest.listdir()) == 1
231231
assert len(source.listdir()) == 1
232232

233-
@py.test.mark.skipif("sys.version_info >= (3,)")
233+
@pytest.mark.skipif("sys.version_info >= (3,)")
234234
def test_2_to_3_bridge_can_send_binary_files(self, tmpdir, makegateway):
235235
python = _find_version("3")
236236
gw = makegateway("popen//python=%s" % python)

testing/test_serializer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _find_version(suffix=""):
2626
return path
2727

2828
else:
29-
py.test.skip("can't find a {!r} executable".format(name))
29+
pytest.skip("can't find a {!r} executable".format(name))
3030
return executable
3131

3232

@@ -147,7 +147,7 @@ def load(request):
147147
]
148148

149149

150-
@py.test.mark.parametrize(["tp_name", "repr"], simple_tests)
150+
@pytest.mark.parametrize(["tp_name", "repr"], simple_tests)
151151
def test_simple(tp_name, repr, dump, load):
152152
if (
153153
sys.platform.startswith("win")

testing/test_termination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_endmarker_delivery_on_remote_killterm(makegateway, execmodel):
5757
@skip_win_pypy
5858
def test_termination_on_remote_channel_receive(monkeypatch, makegateway):
5959
if not py.path.local.sysfind("ps"):
60-
py.test.skip("need 'ps' command to externally check process status")
60+
pytest.skip("need 'ps' command to externally check process status")
6161
monkeypatch.setenv("EXECNET_DEBUG", "2")
6262
gw = makegateway("popen")
6363
pid = gw.remote_exec("import os ; channel.send(os.getpid())").receive()

testing/test_threadpool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def f():
126126
raise ValueError("42")
127127

128128
reply = pool.spawn(f)
129-
with py.test.raises(ValueError):
129+
with pytest.raises(ValueError):
130130
reply.get(1.0)
131131
with pytest.raises(ValueError):
132132
reply.get(1.0)
@@ -145,7 +145,7 @@ def f():
145145
assert pool.waitall(timeout=0.1)
146146

147147

148-
@py.test.mark.skipif("not hasattr(os, 'dup')")
148+
@pytest.mark.skipif("not hasattr(os, 'dup')")
149149
def test_pool_clean_shutdown(pool):
150150
capture = py.io.StdCaptureFD()
151151
q = pool.execmodel.queue.Queue()

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ envlist=py27,py37,docs,linting
44
[testenv]
55
deps=
66
setuptools_scm
7+
py
78
pytest
89
pytest-timeout
910
passenv = GITHUB_ACTIONS
@@ -29,5 +30,4 @@ commands = pre-commit run --all-files --show-diff-on-failure
2930
[pytest]
3031
timeout = 20
3132
addopts = -ra
32-
rsyncdirs = execnet testing
3333
testpaths = testing

0 commit comments

Comments
 (0)