remove an old duplicate marker and use recent pytest mechanism for parametrization

This commit is contained in:
holger krekel 2013-11-21 14:40:14 +01:00
parent e31f40c2d0
commit 2700a94d49
6 changed files with 14 additions and 28 deletions

View File

@ -12,10 +12,6 @@ def pytest_addoption(parser):
help=("run FD checks if lsof is available"))
def pytest_configure(config):
config.addinivalue_line("markers",
"multi(arg=[value1,value2, ...]): call the test function "
"multiple times with arg=value1, then with arg=value2, ... "
)
if config.getvalue("lsof"):
try:
out = py.process.cmdexec("lsof -p %d" % pid)
@ -57,19 +53,6 @@ def pytest_runtest_teardown(item, __multicall__):
check_open_files(item.config)
return x
def pytest_generate_tests(metafunc):
multi = getattr(metafunc.function, 'multi', None)
if multi is not None:
assert len(multi.kwargs) == 1
for name, l in multi.kwargs.items():
for val in l:
metafunc.addcall(funcargs={name: val})
elif 'anypython' in metafunc.fixturenames:
for name in ('python2.5', 'python2.6',
'python2.7', 'python3.2', "python3.3",
'pypy', 'jython'):
metafunc.addcall(id=name, param=name)
# XXX copied from execnet's conftest.py - needs to be merged
winpymap = {
'python2.7': r'C:\Python27\python.exe',
@ -100,7 +83,10 @@ def getexecutable(name, cache={}):
cache[name] = executable
return executable
def pytest_funcarg__anypython(request):
@pytest.fixture(params=['python2.5', 'python2.6',
'python2.7', 'python3.2', "python3.3",
'pypy', 'jython'])
def anypython(request):
name = request.param
executable = getexecutable(name)
if executable is None:

View File

@ -32,7 +32,7 @@ class TestCaptureManager:
assert capman._getmethod(config, sub.join("test_hello.py")) == mode
@needsosdup
@pytest.mark.multi(method=['no', 'fd', 'sys'])
@pytest.mark.parametrize("method", ['no', 'fd', 'sys'])
def test_capturing_basic_api(self, method):
capouter = py.io.StdCaptureFD()
old = sys.stdout, sys.stderr, sys.stdin
@ -81,7 +81,7 @@ class TestCaptureManager:
capouter.reset()
@pytest.mark.xfail("hasattr(sys, 'pypy_version_info')")
@pytest.mark.multi(method=['fd', 'sys'])
@pytest.mark.parametrize("method", ['fd', 'sys'])
def test_capturing_unicode(testdir, method):
if sys.version_info >= (3,0):
obj = "'b\u00f6y'"
@ -100,7 +100,7 @@ def test_capturing_unicode(testdir, method):
"*1 passed*"
])
@pytest.mark.multi(method=['fd', 'sys'])
@pytest.mark.parametrize("method", ['fd', 'sys'])
def test_capturing_bytes_in_utf8_encoding(testdir, method):
testdir.makepyfile("""
def test_unicode():

View File

@ -41,7 +41,7 @@ class TestParseIni:
"*tox.ini:2*requires*9.0*actual*"
])
@pytest.mark.multi(name="setup.cfg tox.ini pytest.ini".split())
@pytest.mark.parametrize("name", "setup.cfg tox.ini pytest.ini".split())
def test_ini_names(self, testdir, name):
testdir.tmpdir.join(name).write(py.std.textwrap.dedent("""
[pytest]

View File

@ -182,7 +182,7 @@ def test_setinitial_confcut(testdir):
assert conftest.getconftestmodules(sub) == []
assert conftest.getconftestmodules(conf.dirpath()) == []
@pytest.mark.multi(name='test tests whatever .dotdir'.split())
@pytest.mark.parametrize("name", 'test tests whatever .dotdir'.split())
def test_setinitial_conftest_subdirs(testdir, name):
sub = testdir.mkdir(name)
subconftest = sub.ensure("conftest.py")

View File

@ -124,7 +124,7 @@ def test_strict_prohibits_unregistered_markers(testdir):
"*unregisteredmark*not*registered*",
])
@pytest.mark.multi(spec=[
@pytest.mark.parametrize("spec", [
("xyz", ("test_one",)),
("xyz and xyz2", ()),
("xyz2", ("test_two",)),
@ -147,7 +147,7 @@ def test_mark_option(spec, testdir):
assert len(passed) == len(passed_result)
assert list(passed) == list(passed_result)
@pytest.mark.multi(spec=[
@pytest.mark.parametrize("spec", [
("interface", ("test_interface",)),
("not interface", ("test_nointer",)),
])
@ -172,7 +172,7 @@ def test_mark_option_custom(spec, testdir):
assert len(passed) == len(passed_result)
assert list(passed) == list(passed_result)
@pytest.mark.multi(spec=[
@pytest.mark.parametrize("spec", [
("interface", ("test_interface",)),
("not interface", ("test_nointer",)),
])

View File

@ -236,7 +236,7 @@ def test_setup_class(testdir):
reprec.assertoutcome(passed=3)
@pytest.mark.multi(type=['Error', 'Failure'])
@pytest.mark.parametrize("type", ['Error', 'Failure'])
def test_testcase_adderrorandfailure_defers(testdir, type):
testdir.makepyfile("""
from unittest import TestCase
@ -256,7 +256,7 @@ def test_testcase_adderrorandfailure_defers(testdir, type):
result = testdir.runpytest()
assert 'should not raise' not in result.stdout.str()
@pytest.mark.multi(type=['Error', 'Failure'])
@pytest.mark.parametrize("type", ['Error', 'Failure'])
def test_testcase_custom_exception_info(testdir, type):
testdir.makepyfile("""
from unittest import TestCase