Skip to content

Commit d62f6a3

Browse files
committed
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
1 parent c90add3 commit d62f6a3

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

testing/conftest.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ def pytest_addoption(parser):
3939
group.addoption(
4040
'--gx', action="append", dest="gspecs", default=None,
4141
help="add a global test environment, XSpec-syntax. ")
42-
group.addoption(
43-
'--gwscope', action="store", dest="scope", default="session",
44-
type="choice", choices=["session", "function"],
45-
help="set gateway setup scope, default: session.")
4642
group.addoption(
4743
'--pypy', action="store_true", dest="pypy",
4844
help="run some tests also against pypy")
@@ -52,13 +48,6 @@ def pytest_addoption(parser):
5248
"page on invalid addresses"))
5349

5450

55-
def pytest_report_header(config):
56-
return [
57-
"gateway test setup scope: %s" % config.getvalue("scope"),
58-
"execnet: {} -- {}".format(execnet.__file__, execnet.__version__),
59-
]
60-
61-
6251
@pytest.fixture
6352
def specssh(request):
6453
return getspecssh(request.config)
@@ -151,15 +140,15 @@ def anypython(request):
151140
return executable
152141

153142

143+
@pytest.fixture(scope='session')
144+
def group():
145+
g = execnet.Group()
146+
yield g
147+
g.terminate(timeout=1)
148+
149+
154150
@pytest.fixture
155-
def gw(request, execmodel):
156-
scope = request.config.option.scope
157-
group = request.cached_setup(
158-
setup=execnet.Group,
159-
teardown=lambda group: group.terminate(timeout=1),
160-
extrakey="testgroup",
161-
scope=scope,
162-
)
151+
def gw(request, execmodel, group):
163152
try:
164153
return group[request.param]
165154
except KeyError:
@@ -188,6 +177,8 @@ def gw(request, execmodel):
188177
group.makegateway('popen//id=proxy-transport')
189178
gw = group.makegateway('popen//via=proxy-transport//id=proxy'
190179
'//execmodel=%s' % execmodel.backend)
180+
else:
181+
assert 0, "unknown execmodel: {}".format(request.param)
191182
return gw
192183

193184

0 commit comments

Comments
 (0)