* don't add distributed command line options when 'execnet' is not
installed, report a nice message. * fix tests and code to work with non-existing execnet * point execnet doc to the new package --HG-- branch : trunk
This commit is contained in:
4
testing/pytest/dist/conftest.py
vendored
Normal file
4
testing/pytest/dist/conftest.py
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
try:
|
||||
import execnet
|
||||
except ImportError:
|
||||
collect_ignore = ['.']
|
||||
@@ -1,4 +1,5 @@
|
||||
import py
|
||||
py.test.importorskip("execnet")
|
||||
from py.__.test.looponfail.remote import LooponfailingSession, LoopState, RemoteControl
|
||||
|
||||
class TestRemoteControl:
|
||||
|
||||
@@ -10,6 +10,7 @@ def test_implied_different_sessions(tmpdir):
|
||||
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'
|
||||
@@ -31,6 +32,8 @@ def test_plugin_already_exists(testdir):
|
||||
|
||||
|
||||
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()
|
||||
@@ -64,13 +67,13 @@ class TestDistOptions:
|
||||
assert py.path.local('z') in roots
|
||||
assert testdir.tmpdir.join('x') in roots
|
||||
|
||||
def test_dist_options(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_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):
|
||||
|
||||
@@ -44,7 +44,8 @@ class TestPDB:
|
||||
if child.isalive():
|
||||
child.wait()
|
||||
|
||||
def test_incompatibility_messages(self, testdir):
|
||||
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")
|
||||
|
||||
@@ -3,6 +3,10 @@ terminal reporting of the full testing process.
|
||||
"""
|
||||
import py
|
||||
import sys
|
||||
try:
|
||||
import execnet
|
||||
except ImportError:
|
||||
execnet = None
|
||||
|
||||
# ===============================================================================
|
||||
# plugin tests
|
||||
@@ -42,7 +46,7 @@ def pytest_generate_tests(metafunc):
|
||||
funcargs={'option': Option(verbose=True)}
|
||||
)
|
||||
nodist = getattr(metafunc.function, 'nodist', False)
|
||||
if not nodist:
|
||||
if execnet and not nodist:
|
||||
metafunc.addcall(
|
||||
id="verbose-dist",
|
||||
funcargs={'option': Option(dist='each', verbose=True)}
|
||||
@@ -602,9 +606,10 @@ class TestTerminalFunctional:
|
||||
"*test_verbose_reporting.py:10: test_gen*FAIL*",
|
||||
])
|
||||
assert result.ret == 1
|
||||
result = testdir.runpytest(p1, '-v', '-n 1')
|
||||
result.stdout.fnmatch_lines([
|
||||
"*FAIL*test_verbose_reporting.py:2: test_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
|
||||
|
||||
|
||||
@@ -218,6 +218,7 @@ class TestOptionEffects:
|
||||
config = py.test.config._reparse([tmpdir])
|
||||
config.initsession()
|
||||
assert not config.option.boxed
|
||||
py.test.importorskip("execnet")
|
||||
config = py.test.config._reparse(['-d', tmpdir])
|
||||
config.initsession()
|
||||
assert not config.option.boxed
|
||||
|
||||
@@ -8,6 +8,12 @@ class TestParser:
|
||||
out, err = capsys.readouterr()
|
||||
assert out.find("xyz") != -1
|
||||
|
||||
def test_epilog(self):
|
||||
parser = parseopt.Parser()
|
||||
assert not parser.epilog
|
||||
parser.epilog += "hello"
|
||||
assert parser.epilog == "hello"
|
||||
|
||||
def test_group_add_and_get(self):
|
||||
parser = parseopt.Parser()
|
||||
group = parser.addgroup("hello", description="desc")
|
||||
@@ -70,6 +76,15 @@ class TestParser:
|
||||
args = parser.parse_setoption([], option)
|
||||
assert option.hello == "x"
|
||||
|
||||
def test_parser_epilog(self, testdir):
|
||||
testdir.makeconftest("""
|
||||
def pytest_addoption(parser):
|
||||
parser.epilog = "hello world"
|
||||
""")
|
||||
result = testdir.runpytest('--help')
|
||||
#assert result.ret != 0
|
||||
assert result.stdout.fnmatch_lines(["*hello world*"])
|
||||
|
||||
def test_parse_setoption(self):
|
||||
parser = parseopt.Parser()
|
||||
parser.addoption("--hello", dest="hello", action="store")
|
||||
|
||||
Reference in New Issue
Block a user