remove dist-testing and looponfail code from core. there remain some (pytest_runner particularly) tests that test both plain and dist modes which cannot be easily dis-entangled. food for thought.

--HG--
branch : trunk
This commit is contained in:
holger krekel
2010-01-13 16:00:33 +01:00
parent d4f5073076
commit 40f41496d8
63 changed files with 343 additions and 3170 deletions

View File

@@ -1,21 +1,6 @@
import py
from py.plugin.pytest_default import pytest_report_iteminfo
def test_implied_different_sessions(testdir, tmpdir):
def x(*args):
config = testdir.reparseconfig([tmpdir] + list(args))
try:
config.pluginmanager.do_configure(config)
except ValueError:
return Exception
return getattr(config._sessionclass, '__name__', None)
assert x() == None
py.test.importorskip("execnet")
assert x('-d') == 'DSession'
assert x('--dist=each') == 'DSession'
assert x('-n3') == 'DSession'
assert x('-f') == 'LooponfailingSession'
def test_plugin_specify(testdir):
testdir.chdir()
config = py.test.raises(ImportError, """
@@ -40,50 +25,6 @@ def test_exclude(testdir):
assert result.ret == 0
assert result.stdout.fnmatch_lines(["*1 passed*"])
class TestDistOptions:
def setup_method(self, method):
py.test.importorskip("execnet")
def test_getxspecs(self, testdir):
config = testdir.parseconfigure("--tx=popen", "--tx", "ssh=xyz")
xspecs = config.getxspecs()
assert len(xspecs) == 2
print(xspecs)
assert xspecs[0].popen
assert xspecs[1].ssh == "xyz"
def test_xspecs_multiplied(self, testdir):
xspecs = testdir.parseconfigure("--tx=3*popen",).getxspecs()
assert len(xspecs) == 3
assert xspecs[1].popen
def test_getrsyncdirs(self, testdir):
config = testdir.parseconfigure('--rsyncdir=' + str(testdir.tmpdir))
roots = config.getrsyncdirs()
assert len(roots) == 1 + 1 # pylib itself
assert testdir.tmpdir in roots
def test_getrsyncdirs_with_conftest(self, testdir):
p = py.path.local()
for bn in 'x y z'.split():
p.mkdir(bn)
testdir.makeconftest("""
rsyncdirs= 'x',
""")
config = testdir.parseconfigure(testdir.tmpdir, '--rsyncdir=y', '--rsyncdir=z')
roots = config.getrsyncdirs()
assert len(roots) == 3 + 1 # pylib itself
assert py.path.local('y') in roots
assert py.path.local('z') in roots
assert testdir.tmpdir.join('x') in roots
def test_dist_options(self, testdir):
config = testdir.parseconfigure("-n 2")
assert config.option.dist == "load"
assert config.option.tx == ['popen'] * 2
config = testdir.parseconfigure("-d")
assert config.option.dist == "load"
def test_pytest_report_iteminfo():
class FakeItem(object):

View File

@@ -25,13 +25,14 @@ def test_gen(testdir, anypython, standalone):
"*imported from*mypytest"
])
def test_rundist(testdir, standalone):
def test_rundist(testdir, pytestconfig, standalone):
pytestconfig.pluginmanager.skipifmissing("xdist")
testdir.makepyfile("""
def test_one():
pass
""")
result = standalone.run(sys.executable, testdir, '-n', '3')
assert result.ret == 2
result.stderr.fnmatch_lines([
"*no such option*"
assert result.ret == 0
result.stdout.fnmatch_lines([
"*1 passed*",
])

View File

@@ -43,14 +43,3 @@ class TestPDB:
child.expect("1 failed")
if child.isalive():
child.wait()
def test_dist_incompatibility_messages(self, testdir):
py.test.importorskip("execnet")
Error = py.test.config.Error
py.test.raises(Error, "testdir.parseconfigure('--pdb', '--looponfail')")
result = testdir.runpytest("--pdb", "-n", "3")
assert result.ret != 0
assert "incompatible" in result.stderr.str()
result = testdir.runpytest("--pdb", "-d", "--tx", "popen")
assert result.ret != 0
assert "incompatible" in result.stderr.str()

View File

@@ -221,7 +221,9 @@ class TestExecutionForked(BaseFunctionalTests):
pytestmark = py.test.mark.skipif("not hasattr(os, 'fork')")
def getrunner(self):
return runner.forked_run_report
# XXX re-arrange this test to live in pytest-xdist
xplugin = py.test.importorskip("xdist.plugin")
return xplugin.forked_run_report
def test_suicide(self, testdir):
reports = testdir.runitem("""
@@ -262,19 +264,6 @@ class TestCollectionReports:
assert not rep.passed
assert rep.skipped
@py.test.mark.skipif("not hasattr(os, 'fork')")
def test_functional_boxed(testdir):
p1 = testdir.makepyfile("""
import os
def test_function():
os.kill(os.getpid(), 15)
""")
result = testdir.runpytest(p1, "--boxed")
assert result.stdout.fnmatch_lines([
"*CRASHED*",
"*1 failed*"
])
def test_callinfo():
ci = runner.CallInfo(lambda: 0, '123')
assert ci.when == "123"

View File

@@ -3,10 +3,6 @@ terminal reporting of the full testing process.
"""
import py
import sys
try:
import execnet
except ImportError:
execnet = None
# ===============================================================================
# plugin tests
@@ -45,12 +41,13 @@ def pytest_generate_tests(metafunc):
id="verbose",
funcargs={'option': Option(verbose=True)}
)
nodist = getattr(metafunc.function, 'nodist', False)
if execnet and not nodist:
metafunc.addcall(
id="verbose-dist",
funcargs={'option': Option(dist='each', verbose=True)}
)
if metafunc.config.pluginmanager.hasplugin("xdist"):
nodist = getattr(metafunc.function, 'nodist', False)
if not nodist:
metafunc.addcall(
id="verbose-dist",
funcargs={'option': Option(dist='each', verbose=True)}
)
class TestTerminal:
def test_pass_skip_fail(self, testdir, option):
@@ -545,7 +542,7 @@ class TestTerminalFunctional:
"y* = 'xxxxxx*"
])
def test_verbose_reporting(self, testdir):
def test_verbose_reporting(self, testdir, pytestconfig):
p1 = testdir.makepyfile("""
import py
def test_fail():
@@ -568,12 +565,12 @@ class TestTerminalFunctional:
"*test_verbose_reporting.py:10: test_gen*FAIL*",
])
assert result.ret == 1
if execnet:
result = testdir.runpytest(p1, '-v', '-n 1')
result.stdout.fnmatch_lines([
"*FAIL*test_verbose_reporting.py:2: test_fail*",
])
assert result.ret == 1
pytestconfig.pluginmanager.skipifmissing("xdist")
result = testdir.runpytest(p1, '-v', '-n 1')
result.stdout.fnmatch_lines([
"*FAIL*test_verbose_reporting.py:2: test_fail*",
])
assert result.ret == 1
def test_getreportopt():