Resolve upcoming pytest deprecations
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
bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1732795
gecko-commit: d0f3bf6ad3a32824fd86614fd8b4e94f0d4e45aa
gecko-reviewers: webdriver-reviewers, ahal, whimboo
diff --git a/resources/test/conftest.py b/resources/test/conftest.py
index 6195dcb..7253cac 100644
--- a/resources/test/conftest.py
+++ b/resources/test/conftest.py
@@ -29,12 +29,12 @@
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
@@ -43,8 +43,8 @@
# 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):
diff --git a/tools/wptrunner/wptrunner/executors/pytestrunner/runner.py b/tools/wptrunner/wptrunner/executors/pytestrunner/runner.py
index f22d948..f520e09 100644
--- a/tools/wptrunner/wptrunner/executors/pytestrunner/runner.py
+++ b/tools/wptrunner/wptrunner/executors/pytestrunner/runner.py
@@ -64,7 +64,7 @@
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