remove an old duplicate marker and use recent pytest mechanism for parametrization
This commit is contained in:
parent
e31f40c2d0
commit
2700a94d49
|
@ -12,10 +12,6 @@ def pytest_addoption(parser):
|
||||||
help=("run FD checks if lsof is available"))
|
help=("run FD checks if lsof is available"))
|
||||||
|
|
||||||
def pytest_configure(config):
|
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"):
|
if config.getvalue("lsof"):
|
||||||
try:
|
try:
|
||||||
out = py.process.cmdexec("lsof -p %d" % pid)
|
out = py.process.cmdexec("lsof -p %d" % pid)
|
||||||
|
@ -57,19 +53,6 @@ def pytest_runtest_teardown(item, __multicall__):
|
||||||
check_open_files(item.config)
|
check_open_files(item.config)
|
||||||
return x
|
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
|
# XXX copied from execnet's conftest.py - needs to be merged
|
||||||
winpymap = {
|
winpymap = {
|
||||||
'python2.7': r'C:\Python27\python.exe',
|
'python2.7': r'C:\Python27\python.exe',
|
||||||
|
@ -100,7 +83,10 @@ def getexecutable(name, cache={}):
|
||||||
cache[name] = executable
|
cache[name] = executable
|
||||||
return 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
|
name = request.param
|
||||||
executable = getexecutable(name)
|
executable = getexecutable(name)
|
||||||
if executable is None:
|
if executable is None:
|
||||||
|
|
|
@ -32,7 +32,7 @@ class TestCaptureManager:
|
||||||
assert capman._getmethod(config, sub.join("test_hello.py")) == mode
|
assert capman._getmethod(config, sub.join("test_hello.py")) == mode
|
||||||
|
|
||||||
@needsosdup
|
@needsosdup
|
||||||
@pytest.mark.multi(method=['no', 'fd', 'sys'])
|
@pytest.mark.parametrize("method", ['no', 'fd', 'sys'])
|
||||||
def test_capturing_basic_api(self, method):
|
def test_capturing_basic_api(self, method):
|
||||||
capouter = py.io.StdCaptureFD()
|
capouter = py.io.StdCaptureFD()
|
||||||
old = sys.stdout, sys.stderr, sys.stdin
|
old = sys.stdout, sys.stderr, sys.stdin
|
||||||
|
@ -81,7 +81,7 @@ class TestCaptureManager:
|
||||||
capouter.reset()
|
capouter.reset()
|
||||||
|
|
||||||
@pytest.mark.xfail("hasattr(sys, 'pypy_version_info')")
|
@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):
|
def test_capturing_unicode(testdir, method):
|
||||||
if sys.version_info >= (3,0):
|
if sys.version_info >= (3,0):
|
||||||
obj = "'b\u00f6y'"
|
obj = "'b\u00f6y'"
|
||||||
|
@ -100,7 +100,7 @@ def test_capturing_unicode(testdir, method):
|
||||||
"*1 passed*"
|
"*1 passed*"
|
||||||
])
|
])
|
||||||
|
|
||||||
@pytest.mark.multi(method=['fd', 'sys'])
|
@pytest.mark.parametrize("method", ['fd', 'sys'])
|
||||||
def test_capturing_bytes_in_utf8_encoding(testdir, method):
|
def test_capturing_bytes_in_utf8_encoding(testdir, method):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
def test_unicode():
|
def test_unicode():
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestParseIni:
|
||||||
"*tox.ini:2*requires*9.0*actual*"
|
"*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):
|
def test_ini_names(self, testdir, name):
|
||||||
testdir.tmpdir.join(name).write(py.std.textwrap.dedent("""
|
testdir.tmpdir.join(name).write(py.std.textwrap.dedent("""
|
||||||
[pytest]
|
[pytest]
|
||||||
|
|
|
@ -182,7 +182,7 @@ def test_setinitial_confcut(testdir):
|
||||||
assert conftest.getconftestmodules(sub) == []
|
assert conftest.getconftestmodules(sub) == []
|
||||||
assert conftest.getconftestmodules(conf.dirpath()) == []
|
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):
|
def test_setinitial_conftest_subdirs(testdir, name):
|
||||||
sub = testdir.mkdir(name)
|
sub = testdir.mkdir(name)
|
||||||
subconftest = sub.ensure("conftest.py")
|
subconftest = sub.ensure("conftest.py")
|
||||||
|
|
|
@ -124,7 +124,7 @@ def test_strict_prohibits_unregistered_markers(testdir):
|
||||||
"*unregisteredmark*not*registered*",
|
"*unregisteredmark*not*registered*",
|
||||||
])
|
])
|
||||||
|
|
||||||
@pytest.mark.multi(spec=[
|
@pytest.mark.parametrize("spec", [
|
||||||
("xyz", ("test_one",)),
|
("xyz", ("test_one",)),
|
||||||
("xyz and xyz2", ()),
|
("xyz and xyz2", ()),
|
||||||
("xyz2", ("test_two",)),
|
("xyz2", ("test_two",)),
|
||||||
|
@ -147,7 +147,7 @@ def test_mark_option(spec, testdir):
|
||||||
assert len(passed) == len(passed_result)
|
assert len(passed) == len(passed_result)
|
||||||
assert list(passed) == list(passed_result)
|
assert list(passed) == list(passed_result)
|
||||||
|
|
||||||
@pytest.mark.multi(spec=[
|
@pytest.mark.parametrize("spec", [
|
||||||
("interface", ("test_interface",)),
|
("interface", ("test_interface",)),
|
||||||
("not interface", ("test_nointer",)),
|
("not interface", ("test_nointer",)),
|
||||||
])
|
])
|
||||||
|
@ -172,7 +172,7 @@ def test_mark_option_custom(spec, testdir):
|
||||||
assert len(passed) == len(passed_result)
|
assert len(passed) == len(passed_result)
|
||||||
assert list(passed) == list(passed_result)
|
assert list(passed) == list(passed_result)
|
||||||
|
|
||||||
@pytest.mark.multi(spec=[
|
@pytest.mark.parametrize("spec", [
|
||||||
("interface", ("test_interface",)),
|
("interface", ("test_interface",)),
|
||||||
("not interface", ("test_nointer",)),
|
("not interface", ("test_nointer",)),
|
||||||
])
|
])
|
||||||
|
|
|
@ -236,7 +236,7 @@ def test_setup_class(testdir):
|
||||||
reprec.assertoutcome(passed=3)
|
reprec.assertoutcome(passed=3)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.multi(type=['Error', 'Failure'])
|
@pytest.mark.parametrize("type", ['Error', 'Failure'])
|
||||||
def test_testcase_adderrorandfailure_defers(testdir, type):
|
def test_testcase_adderrorandfailure_defers(testdir, type):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
@ -256,7 +256,7 @@ def test_testcase_adderrorandfailure_defers(testdir, type):
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
assert 'should not raise' not in result.stdout.str()
|
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):
|
def test_testcase_custom_exception_info(testdir, type):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
Loading…
Reference in New Issue