Merge pull request #3044 from RonnyPfannschmidt/parameterset-empty-enable-xfail
empty parameterset - enable opt to xfail
This commit is contained in:
@@ -14,7 +14,7 @@ PY3 = sys.version_info >= (3, 0)
|
||||
|
||||
|
||||
class TestMetafunc(object):
|
||||
def Metafunc(self, func):
|
||||
def Metafunc(self, func, config=None):
|
||||
# the unit tests of this class check if things work correctly
|
||||
# on the funcarg level, so we don't need a full blown
|
||||
# initiliazation
|
||||
@@ -26,7 +26,7 @@ class TestMetafunc(object):
|
||||
|
||||
names = fixtures.getfuncargnames(func)
|
||||
fixtureinfo = FixtureInfo(names)
|
||||
return python.Metafunc(func, fixtureinfo, None)
|
||||
return python.Metafunc(func, fixtureinfo, config)
|
||||
|
||||
def test_no_funcargs(self, testdir):
|
||||
def function():
|
||||
@@ -156,7 +156,19 @@ class TestMetafunc(object):
|
||||
def test_parametrize_empty_list(self):
|
||||
def func(y):
|
||||
pass
|
||||
metafunc = self.Metafunc(func)
|
||||
|
||||
class MockConfig(object):
|
||||
def getini(self, name):
|
||||
return ''
|
||||
|
||||
@property
|
||||
def hook(self):
|
||||
return self
|
||||
|
||||
def pytest_make_parametrize_id(self, **kw):
|
||||
pass
|
||||
|
||||
metafunc = self.Metafunc(func, MockConfig())
|
||||
metafunc.parametrize("y", [])
|
||||
assert 'skip' == metafunc._calls[0].marks[0].name
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@ import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from _pytest.mark import MarkGenerator as Mark, ParameterSet, transfer_markers
|
||||
from _pytest.mark import (
|
||||
MarkGenerator as Mark, ParameterSet, transfer_markers,
|
||||
EMPTY_PARAMETERSET_OPTION,
|
||||
)
|
||||
|
||||
|
||||
class TestMark(object):
|
||||
@@ -891,3 +894,27 @@ class TestMarkDecorator(object):
|
||||
])
|
||||
def test__eq__(self, lhs, rhs, expected):
|
||||
assert (lhs == rhs) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize('mark', [None, '', 'skip', 'xfail'])
|
||||
def test_parameterset_for_parametrize_marks(testdir, mark):
|
||||
if mark is not None:
|
||||
testdir.makeini(
|
||||
"[pytest]\n{}={}".format(EMPTY_PARAMETERSET_OPTION, mark))
|
||||
|
||||
config = testdir.parseconfig()
|
||||
from _pytest.mark import pytest_configure, get_empty_parameterset_mark
|
||||
pytest_configure(config)
|
||||
result_mark = get_empty_parameterset_mark(config, ['a'], all)
|
||||
if mark in (None, ''):
|
||||
# normalize to the requested name
|
||||
mark = 'skip'
|
||||
assert result_mark.name == mark
|
||||
assert result_mark.kwargs['reason'].startswith("got empty parameter set ")
|
||||
if mark == 'xfail':
|
||||
assert result_mark.kwargs.get('run') is False
|
||||
|
||||
|
||||
def test_parameterset_for_parametrize_bad_markname(testdir):
|
||||
with pytest.raises(pytest.UsageError):
|
||||
test_parameterset_for_parametrize_marks(testdir, 'bad')
|
||||
|
||||
Reference in New Issue
Block a user