Add tests for interactions between boxed, dist and collect-only.
Re-enable parsing of the boxed option with collect-only
This commit is contained in:
committed by
James Bungard
parent
c83f73e19c
commit
7674f6b186
@@ -262,6 +262,16 @@ class TestDistribution:
|
||||
child.close()
|
||||
# assert ret == 2
|
||||
|
||||
def test_dist_with_collectonly(self, testdir):
|
||||
p1 = testdir.makepyfile("""
|
||||
def test_ok():
|
||||
pass
|
||||
""")
|
||||
result = testdir.runpytest(p1, "-n1", "--collect-only")
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
"*collected 1 item*",
|
||||
])
|
||||
|
||||
class TestDistEach:
|
||||
def test_simple(self, testdir):
|
||||
|
||||
@@ -43,6 +43,33 @@ def test_auto_detect_cpus(testdir, monkeypatch):
|
||||
config = testdir.parseconfigure("-nauto")
|
||||
assert config.getoption('numprocesses') == 99
|
||||
|
||||
def test_boxed_with_collect_only(testdir):
|
||||
from xdist.plugin import pytest_cmdline_main as check_options
|
||||
config = testdir.parseconfigure("-n1", "--boxed")
|
||||
check_options(config)
|
||||
assert config.option.forked
|
||||
|
||||
config = testdir.parseconfigure("-n1", "--collect-only")
|
||||
check_options(config)
|
||||
assert not config.option.forked
|
||||
|
||||
config = testdir.parseconfigure("-n1", "--boxed", "--collect-only")
|
||||
check_options(config)
|
||||
assert config.option.forked
|
||||
|
||||
def test_dsession_with_collect_only(testdir):
|
||||
from xdist.plugin import pytest_cmdline_main as check_options
|
||||
from xdist.plugin import pytest_configure as configure
|
||||
|
||||
config = testdir.parseconfigure("-n1")
|
||||
check_options(config)
|
||||
configure(config)
|
||||
assert config.pluginmanager.hasplugin("dsession")
|
||||
|
||||
config = testdir.parseconfigure("-n1", "--collect-only")
|
||||
check_options(config)
|
||||
configure(config)
|
||||
assert not config.pluginmanager.hasplugin("dsession")
|
||||
|
||||
class TestDistOptions:
|
||||
def test_getxspecs(self, testdir):
|
||||
|
||||
@@ -91,15 +91,14 @@ def pytest_addhooks(pluginmanager):
|
||||
|
||||
@pytest.mark.trylast
|
||||
def pytest_configure(config):
|
||||
if not config.getvalue("collectonly"):
|
||||
if config.getoption("dist") != "no":
|
||||
from xdist.dsession import DSession
|
||||
session = DSession(config)
|
||||
config.pluginmanager.register(session, "dsession")
|
||||
tr = config.pluginmanager.getplugin("terminalreporter")
|
||||
tr.showfspath = False
|
||||
if config.getoption("boxed"):
|
||||
config.option.forked = True
|
||||
if config.getoption("dist") != "no" and not config.getvalue("collectonly"):
|
||||
from xdist.dsession import DSession
|
||||
session = DSession(config)
|
||||
config.pluginmanager.register(session, "dsession")
|
||||
tr = config.pluginmanager.getplugin("terminalreporter")
|
||||
tr.showfspath = False
|
||||
if config.getoption("boxed"):
|
||||
config.option.forked = True
|
||||
|
||||
|
||||
@pytest.mark.tryfirst
|
||||
|
||||
Reference in New Issue
Block a user