зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1732795: Resolve upcoming pytest deprecations r=webdriver-reviewers,ahal,whimboo
Following the pytest "deprecations and removals" docs [1], this patch: * Replaces `@pytest.yield_fixture` with `@pytest.fixture`. * Replaces `.funcargnames` with `.fixturenames`. * Uses `Pathlib` parameter instead of the `py.path.local` one in associated `pytest_*` hooks. * Replaces `--strict` with `--strict-markers` [1] https://docs.pytest.org/en/latest/deprecations.html Differential Revision: https://phabricator.services.mozilla.com/D138815
This commit is contained in:
Родитель
222e16e8b1
Коммит
8d5bcd86f6
|
@ -65,7 +65,7 @@ def shell(cmd, working_dir):
|
|||
subprocess.check_call(step, shell=True, cwd=working_dir)
|
||||
|
||||
|
||||
@pytest.yield_fixture(params=["git", "hg"])
|
||||
@pytest.fixture(params=["git", "hg"])
|
||||
def repo(tmpdir, request):
|
||||
tmpdir = Path(tmpdir)
|
||||
vcs = request.param
|
||||
|
|
|
@ -96,6 +96,6 @@ def mock_httpd(request):
|
|||
def mock_marionette(request):
|
||||
"""Mock marionette instance"""
|
||||
marionette = MagicMock(spec=dir(Marionette()))
|
||||
if "has_crashed" in request.funcargnames:
|
||||
if "has_crashed" in request.fixturenames:
|
||||
marionette.check_for_crash.return_value = request.getfixturevalue("has_crashed")
|
||||
return marionette
|
||||
|
|
|
@ -23,7 +23,7 @@ parent = os.path.dirname(here)
|
|||
default_doc_root = os.path.join(os.path.dirname(parent), "www")
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def server():
|
||||
server = httpd.FixtureServer(default_doc_root)
|
||||
yield server
|
||||
|
|
|
@ -21,7 +21,7 @@ def harness_class(request):
|
|||
Mock based on MarionetteHarness whose run method just returns a number of
|
||||
failures according to the supplied test parameter
|
||||
"""
|
||||
if "num_fails_crashed" in request.funcargnames:
|
||||
if "num_fails_crashed" in request.fixturenames:
|
||||
num_fails_crashed = request.getfixturevalue("num_fails_crashed")
|
||||
else:
|
||||
num_fails_crashed = (0, 0)
|
||||
|
@ -40,7 +40,7 @@ def runner_class(request):
|
|||
Mock based on MarionetteTestRunner, wherein the runner.failed,
|
||||
runner.crashed attributes are provided by a test parameter
|
||||
"""
|
||||
if "num_fails_crashed" in request.funcargnames:
|
||||
if "num_fails_crashed" in request.fixturenames:
|
||||
failures, crashed = request.getfixturevalue("num_fails_crashed")
|
||||
else:
|
||||
failures = 0
|
||||
|
|
|
@ -30,12 +30,12 @@ def pytest_addoption(parser):
|
|||
parser.addoption("--headless", action="store_true", default=False, help="run browser in headless mode")
|
||||
|
||||
|
||||
def pytest_collect_file(path, parent):
|
||||
if path.ext.lower() != '.html':
|
||||
def pytest_collect_file(file_path, path, parent):
|
||||
if file_path.suffix.lower() != '.html':
|
||||
return
|
||||
|
||||
# Tests are organized in directories by type
|
||||
test_type = os.path.relpath(str(path), HERE)
|
||||
test_type = os.path.relpath(str(file_path), HERE)
|
||||
if os.path.sep not in test_type or ".." in test_type:
|
||||
# HTML files in this directory are not tests
|
||||
return
|
||||
|
@ -44,8 +44,8 @@ def pytest_collect_file(path, parent):
|
|||
# Handle the deprecation of Node construction in pytest6
|
||||
# https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
|
||||
if hasattr(HTMLItem, "from_parent"):
|
||||
return HTMLItem.from_parent(parent, filename=str(path), test_type=test_type)
|
||||
return HTMLItem(parent, str(path), test_type)
|
||||
return HTMLItem.from_parent(parent, filename=str(file_path), test_type=test_type)
|
||||
return HTMLItem(parent, str(file_path), test_type)
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
|
|
|
@ -61,7 +61,7 @@ def run(path, server_config, session_config, timeout=0, environ=None):
|
|||
|
||||
try:
|
||||
basetemp = os.path.join(cache, "pytest")
|
||||
pytest.main(["--strict", # turn warnings into errors
|
||||
pytest.main(["--strict-markers", # turn function marker warnings into errors
|
||||
"-vv", # show each individual subtest and full failure logs
|
||||
"--capture", "no", # enable stdout/stderr from tests
|
||||
"--basetemp", basetemp, # temporary directory
|
||||
|
|
Загрузка…
Ссылка в новой задаче