Skip config.warn tests in pytest 4.1

This commit is contained in:
Bruno Oliveira
2019-01-08 09:14:29 -02:00
parent f283dddf36
commit 261d4189f0

View File

@@ -738,10 +738,12 @@ def test_sub_plugins_disabled(testdir, plugin):
class TestWarnings: class TestWarnings:
@pytest.mark.parametrize("n", ["-n0", "-n1"]) @pytest.mark.parametrize("n", ["-n0", "-n1"])
@pytest.mark.parametrize("warn_type", ["pytest", "builtin"]) @pytest.mark.parametrize("warn_type", ["pytest", "builtin"])
def test_warnings(self, testdir, n, warn_type): def test_warnings(self, testdir, n, request, warn_type):
if warn_type == "builtin": if warn_type == "builtin":
warn_code = """warnings.warn(UserWarning('this is a warning'))""" warn_code = """warnings.warn(UserWarning('this is a warning'))"""
elif warn_type == "pytest": elif warn_type == "pytest":
if not hasattr(request.config, "warn"):
pytest.skip("config.warn has been removed in pytest 4.1")
warn_code = """request.config.warn('', 'this is a warning', warn_code = """request.config.warn('', 'this is a warning',
fslocation=py.path.local())""" fslocation=py.path.local())"""
else: else: