Change std_warn to receive a single warning instance, addressed review suggestions
This commit is contained in:
@@ -526,7 +526,7 @@ class TestInvocationVariants(object):
|
||||
assert pytest.main == py.test.cmdline.main
|
||||
|
||||
def test_invoke_with_string(self, capsys):
|
||||
retcode = pytest.main(["-h"])
|
||||
retcode = pytest.main("-h")
|
||||
assert not retcode
|
||||
out, err = capsys.readouterr()
|
||||
assert "--help" in out
|
||||
|
||||
@@ -289,6 +289,7 @@ def test_call_fixture_function_deprecated():
|
||||
|
||||
def test_pycollector_makeitem_is_deprecated():
|
||||
from _pytest.python import PyCollector
|
||||
from _pytest.warning_types import RemovedInPytest4Warning
|
||||
|
||||
class PyCollectorMock(PyCollector):
|
||||
"""evil hack"""
|
||||
@@ -301,6 +302,6 @@ def test_pycollector_makeitem_is_deprecated():
|
||||
self.called = True
|
||||
|
||||
collector = PyCollectorMock()
|
||||
with pytest.deprecated_call():
|
||||
with pytest.warns(RemovedInPytest4Warning):
|
||||
collector.makeitem("foo", "bar")
|
||||
assert collector.called
|
||||
|
||||
@@ -217,7 +217,7 @@ class TestMetafunc(object):
|
||||
def test_idval_hypothesis(self, value):
|
||||
from _pytest.python import _idval
|
||||
|
||||
escaped = _idval(value, "a", 6, None)
|
||||
escaped = _idval(value, "a", 6, None, item=None)
|
||||
assert isinstance(escaped, str)
|
||||
if PY3:
|
||||
escaped.encode("ascii")
|
||||
@@ -244,7 +244,7 @@ class TestMetafunc(object):
|
||||
),
|
||||
]
|
||||
for val, expected in values:
|
||||
assert _idval(val, "a", 6, None) == expected
|
||||
assert _idval(val, "a", 6, None, item=None) == expected
|
||||
|
||||
def test_bytes_idval(self):
|
||||
"""unittest for the expected behavior to obtain ids for parametrized
|
||||
@@ -262,7 +262,7 @@ class TestMetafunc(object):
|
||||
(u"αρά".encode("utf-8"), "\\xce\\xb1\\xcf\\x81\\xce\\xac"),
|
||||
]
|
||||
for val, expected in values:
|
||||
assert _idval(val, "a", 6, None) == expected
|
||||
assert _idval(val, "a", 6, idfn=None, item=None, config=None) == expected
|
||||
|
||||
def test_class_or_function_idval(self):
|
||||
"""unittest for the expected behavior to obtain ids for parametrized
|
||||
@@ -278,7 +278,7 @@ class TestMetafunc(object):
|
||||
|
||||
values = [(TestClass, "TestClass"), (test_function, "test_function")]
|
||||
for val, expected in values:
|
||||
assert _idval(val, "a", 6, None) == expected
|
||||
assert _idval(val, "a", 6, None, item=None) == expected
|
||||
|
||||
@pytest.mark.issue250
|
||||
def test_idmaker_autoname(self):
|
||||
|
||||
@@ -1041,7 +1041,11 @@ class TestKeywordSelection(object):
|
||||
)
|
||||
@pytest.mark.filterwarnings("ignore")
|
||||
def test_parameterset_extractfrom(argval, expected):
|
||||
extracted = ParameterSet.extract_from(argval)
|
||||
class DummyItem:
|
||||
def std_warn(self, warning):
|
||||
pass
|
||||
|
||||
extracted = ParameterSet.extract_from(argval, belonging_definition=DummyItem())
|
||||
assert extracted == expected
|
||||
|
||||
|
||||
|
||||
@@ -19,3 +19,14 @@ from _pytest import nodes
|
||||
def test_ischildnode(baseid, nodeid, expected):
|
||||
result = nodes.ischildnode(baseid, nodeid)
|
||||
assert result is expected
|
||||
|
||||
|
||||
def test_std_warn_not_pytestwarning(testdir):
|
||||
items = testdir.getitems(
|
||||
"""
|
||||
def test():
|
||||
pass
|
||||
"""
|
||||
)
|
||||
with pytest.raises(ValueError, match=".*instance of PytestWarning.*"):
|
||||
items[0].std_warn(UserWarning("some warning"))
|
||||
|
||||
Reference in New Issue
Block a user