Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning with pytest 7 #5

Closed
jaraco opened this issue Feb 5, 2022 · 1 comment
Closed

DeprecationWarning with pytest 7 #5

jaraco opened this issue Feb 5, 2022 · 1 comment

Comments

@jaraco
Copy link
Owner

jaraco commented Feb 5, 2022

I see this error when running with errors:

pytest-perf main $ tox -- --collectonly -We
python develop-inst-noop: /Users/jaraco/code/main/pytest-perf
python installed: attrs==21.4.0,autocommand==2.2.1,black==22.1.0,click==8.0.3,coverage==6.3.1,docutils==0.18.1,filelock==3.4.2,flake8==4.0.1,importlib-metadata==4.10.1,iniconfig==1.1.1,jaraco.context==4.1.1,jaraco.functools==3.5.0,mccabe==0.6.1,more-itertools==8.12.0,mypy==0.931,mypy-extensions==0.4.3,packaging==21.3,path==16.3.0,pathspec==0.9.0,pep517==0.12.0,pip-run==8.8.0,platformdirs==2.4.1,pluggy==1.0.0,py==1.11.0,pycodestyle==2.8.0,pyflakes==2.4.0,pyparsing==3.0.7,pytest==7.0.0,pytest-black==0.3.12,pytest-checkdocs==2.7.1,pytest-cov==3.0.0,pytest-enabler==1.2.1,pytest-flake8==1.0.7,pytest-mypy==0.9.0,-e git+gh://jaraco/pytest-perf@9a7dec311c22746fc052f5c0085c5692e367722d#egg=pytest_perf,pytz==2021.3,tempora==5.0.1,toml==0.10.2,tomli==2.0.0,typing_extensions==4.0.1,zipp==3.7.0
python run-test-pre: PYTHONHASHSEED='3349794569'
python run-test: commands[0] | pytest --collectonly -We
/Users/jaraco/code/main/pytest-perf/.tox/python/lib/python3.10/site-packages/_pytest/nodes.py:664: PytestWarning: Flake8Item is an Item subclass and should not be a collector, however its bases File are collectors.
Please split the Collectors and the Item into separate node types.
Pytest Doc example: https://docs.pytest.org/en/latest/example/nonpython.html
example pull request on a plugin: https://github.com/asmeurer/pytest-flakes/pull/40/
  warnings.warn(
/Users/jaraco/code/main/pytest-perf/.tox/python/lib/python3.10/site-packages/_pytest/nodes.py:664: PytestWarning: BlackItem is an Item subclass and should not be a collector, however its bases File are collectors.
Please split the Collectors and the Item into separate node types.
Pytest Doc example: https://docs.pytest.org/en/latest/example/nonpython.html
example pull request on a plugin: https://github.com/asmeurer/pytest-flakes/pull/40/
  warnings.warn(
====================================================================== test session starts =======================================================================
platform darwin -- Python 3.10.1, pytest-7.0.0, pluggy-1.0.0
cachedir: .tox/python/.pytest_cache
rootdir: /Users/jaraco/code/main/pytest-perf, configfile: pytest.ini
plugins: flake8-1.0.7, enabler-1.2.1, checkdocs-2.7.1, black-0.3.12, mypy-0.9.0, cov-3.0.0, perf-0.11.1.dev3+g9a7dec3
collected 0 items / 1 error                                                                                                                                      

============================================================================= ERRORS =============================================================================
_________________________________________________________________ ERROR collecting test session __________________________________________________________________
.tox/python/lib/python3.10/site-packages/pluggy/_hooks.py:265: in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
.tox/python/lib/python3.10/site-packages/pluggy/_manager.py:80: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
pytest_perf/plugin.py:21: in pytest_collect_file
    return File.from_parent(parent, fspath=path)
.tox/python/lib/python3.10/site-packages/_pytest/nodes.py:633: in from_parent
    return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
.tox/python/lib/python3.10/site-packages/_pytest/nodes.py:264: in from_parent
    return cls._create(parent=parent, **kw)
.tox/python/lib/python3.10/site-packages/_pytest/nodes.py:140: in _create
    return super().__call__(*k, **kw)
.tox/python/lib/python3.10/site-packages/_pytest/nodes.py:588: in __init__
    path = _imply_path(type(self), path, fspath=fspath)
.tox/python/lib/python3.10/site-packages/_pytest/nodes.py:110: in _imply_path
    warnings.warn(
E   pytest.PytestRemovedIn8Warning: The (fspath: py.path.local) argument to File is deprecated. Please use the (path: pathlib.Path) argument instead.
E   See https://docs.pytest.org/en/latest/deprecations.html#fspath-argument-for-node-constructors-replaced-with-pathlib-path

---------- coverage: platform darwin, python 3.10.1-final-0 ----------
Name                    Stmts   Miss  Cover   Missing
-----------------------------------------------------
pytest_perf/plugin.py      76     74     3%   1-17, 24-120
-----------------------------------------------------
TOTAL                      76     74     3%

==================================================================== short test summary info =====================================================================
ERROR  - pytest.PytestRemovedIn8Warning: The (fspath: py.path.local) argument to File is deprecated. Please use the (path: pathlib.Path) argument instead.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================== no tests collected, 1 error in 0.13s ==============================================================
ERROR: InvocationError for command /Users/jaraco/code/main/pytest-perf/.tox/python/bin/pytest --collectonly -We (exited with code 2)
____________________________________________________________________________ summary _____________________________________________________________________________
ERROR:   python: commands failed

Referencing this guide.

@jaraco
Copy link
Owner Author

jaraco commented Feb 5, 2022

In 8cf29ad, I figured out a fix for the issue. Unfortunately, the fix relies on pytest 7, making the plugin incompatible with pytest 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant