Merge pull request #232 from verdesmarald/master
Don't create DSession in collect-only mode
This commit is contained in:
1
changelog/5.bugfix
Normal file
1
changelog/5.bugfix
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Fix issue where the -n option would still run distributed tests when pytest was run with the --collect-only option
|
||||||
@@ -262,6 +262,17 @@ 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):
|
||||||
|
|||||||
@@ -44,6 +44,36 @@ def test_auto_detect_cpus(testdir, monkeypatch):
|
|||||||
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):
|
||||||
config = testdir.parseconfigure("--tx=popen", "--tx", "ssh=xyz")
|
config = testdir.parseconfigure("--tx=popen", "--tx", "ssh=xyz")
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ def pytest_addhooks(pluginmanager):
|
|||||||
|
|
||||||
@pytest.mark.trylast
|
@pytest.mark.trylast
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
if config.getoption("dist") != "no":
|
if config.getoption("dist") != "no" and not config.getvalue("collectonly"):
|
||||||
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")
|
||||||
|
|||||||
Reference in New Issue
Block a user