fix the unit tests, add the proper deprecation warning, and add in a changelog entry

This commit is contained in:
Gleb Nikonorov
2020-05-27 23:03:07 -04:00
parent d742b386c3
commit 14de08011b
4 changed files with 23 additions and 33 deletions

View File

@@ -1,5 +1,4 @@
import os
import re
import warnings
import pytest
@@ -276,25 +275,11 @@ def test_warning_captured_hook(testdir):
result.stdout.fnmatch_lines(["*1 passed*"])
expected = [
(
"config warning",
"config",
"",
(
r"/tmp/pytest-of-.+/pytest-\d+/test_warning_captured_hook0/conftest.py",
3,
"pytest_configure",
),
),
("collect warning", "collect", "", None),
("setup warning", "runtest", "test_warning_captured_hook.py::test_func", None),
("call warning", "runtest", "test_warning_captured_hook.py::test_func", None),
(
"teardown warning",
"runtest",
"test_warning_captured_hook.py::test_func",
None,
),
("config warning", "config", "",),
("collect warning", "collect", ""),
("setup warning", "runtest", "test_warning_captured_hook.py::test_func"),
("call warning", "runtest", "test_warning_captured_hook.py::test_func"),
("teardown warning", "runtest", "test_warning_captured_hook.py::test_func"),
]
for index in range(len(expected)):
collected_result = collected[index]
@@ -304,14 +289,15 @@ def test_warning_captured_hook(testdir):
assert collected_result[1] == expected_result[1], str(collected)
assert collected_result[2] == expected_result[2], str(collected)
if expected_result[3] is not None:
assert re.match(expected_result[3][0], collected_result[3][0]), str(
collected
)
assert collected_result[3][1] == expected_result[3][1], str(collected)
assert collected_result[3][2] == expected_result[3][2], str(collected)
# NOTE: collected_result[3] is location, which differs based on the platform you are on
# thus, the best we can do here is assert the types of the paremeters match what we expect
# and not try and preload it in the expected array
if collected_result[3] is not None:
assert type(collected_result[3][0]) is str, str(collected)
assert type(collected_result[3][1]) is int, str(collected)
assert type(collected_result[3][2]) is str, str(collected)
else:
assert expected_result[3] == collected_result[3], str(collected)
assert collected_result[3] is None, str(collected)
@pytest.mark.filterwarnings("always")