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:
verdesmarald
2017-09-07 16:05:25 +10:00
committed by James Bungard
parent c83f73e19c
commit 7674f6b186
3 changed files with 45 additions and 9 deletions

View File

@@ -262,6 +262,16 @@ class TestDistribution:
child.close() child.close()
# assert ret == 2 # 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: class TestDistEach:
def test_simple(self, testdir): def test_simple(self, testdir):

View File

@@ -43,6 +43,33 @@ def test_auto_detect_cpus(testdir, monkeypatch):
config = testdir.parseconfigure("-nauto") config = testdir.parseconfigure("-nauto")
assert config.getoption('numprocesses') == 99 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: class TestDistOptions:
def test_getxspecs(self, testdir): def test_getxspecs(self, testdir):

View File

@@ -91,15 +91,14 @@ def pytest_addhooks(pluginmanager):
@pytest.mark.trylast @pytest.mark.trylast
def pytest_configure(config): def pytest_configure(config):
if not config.getvalue("collectonly"): if config.getoption("dist") != "no" and not config.getvalue("collectonly"):
if config.getoption("dist") != "no": from xdist.dsession import DSession
from xdist.dsession import DSession session = DSession(config)
session = DSession(config) config.pluginmanager.register(session, "dsession")
config.pluginmanager.register(session, "dsession") tr = config.pluginmanager.getplugin("terminalreporter")
tr = config.pluginmanager.getplugin("terminalreporter") tr.showfspath = False
tr.showfspath = False if config.getoption("boxed"):
if config.getoption("boxed"): config.option.forked = True
config.option.forked = True
@pytest.mark.tryfirst @pytest.mark.tryfirst