wntrblm / nox

Flexible test automation for Python
https://nox.thea.codes
Apache License 2.0
1.3k stars 148 forks source link

4 errors during tests: <class 'pytest_black.BlackItem'> is not using a cooperative constructor and only takes {'parent', 'fspath'} #792

Closed yurivict closed 6 months ago

yurivict commented 6 months ago

Current Behavior

Pytest-7.4.3 is used, while pyproject.toml has minversion = "6.0".

There are 4 errors in tests:

===>   nox-2024.3.2 depends on file: /usr/local/bin/python3.9 - found
cd /usr/ports/devel/nox/work-py39/nox-2024.03.02 && /usr/bin/env -i HOME=/usr/ports/devel/nox/work-py39  PWD="${PWD}" OSVERSION=1400502 PATH=/usr/local/libexec/ccache:/usr/ports/devel/nox/work-py39/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin TERM=xterm-256color XDG_DATA_HOME=/usr/ports/devel/nox/work-py39  XDG_CONFIG_HOME=/usr/ports/devel/nox/work-py39  XDG_CACHE_HOME=/usr/ports/devel/nox/work-py39/.cache  HOME=/usr/ports/devel/nox/work-py39 PATH=/usr/local/libexec/ccache:/usr/ports/devel/nox/work-py39/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin PKG_CONFIG_LIBDIR=/usr/ports/devel/nox/work-py39/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local  LOCALBASE=/usr/local  CC="cc" CFLAGS="-O2 -pipe  -fstack-protector-strong -fno-strict-aliasing "  CPP="cpp" CPPFLAGS=""  LDFLAGS=" -fstack-protector-strong " LIBS=""  CXX="c++" CXXFLAGS="-O2 -pipe -fstack-protector-strong -fno-strict-aliasing  " CCACHE_DIR="/tmp/.ccache" BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 0644"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444" /usr/local/bin/python3.9 -m pytest -k '' -rs -v -o addopts= 
[03/04/24 08:52:44] WARNING  pyproject.toml does not contain a tool.setuptools_scm section                                                                                  setuptools.py:119
==================================================================================== test session starts ====================================================================================
platform freebsd14 -- Python 3.9.18, pytest-7.4.3, pluggy-1.3.0 -- /usr/local/bin/python3.9
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/usr/ports/devel/nox/work-py39/nox-2024.03.02/.hypothesis/examples'))
Using --randomly-seed=4101453535
rootdir: /usr/ports/devel/nox/work-py39/nox-2024.03.02
configfile: pyproject.toml
testpaths: tests
plugins: anyio-4.1.0, hypothesis-6.92.1, datadir-1.5.0, cov-4.1.0, randomly-3.12.0, timeout-2.1.0, time-machine-2.11.0, forked-1.6.0, rerunfailures-11.1.2, flaky-3.7.0, aspectlib-2.0.0, xdist-3.5.0, env-0.6.2, mock-3.10.0, black-0.3.12, checkdocs-2.10.1, mypy-0.10.3, flake8-1.1.1, black-multipy-1.0.1, enabler-3.0.0, typeguard-4.1.5
initialized: 3/4 workers[03/04/24 08:52:48] WARNING  pyproject.toml does not contain a tool.setuptools_scm section                                                                                  setuptools.py:119
ready: 1/4 workers      [03/04/24 08:52:49] WARNING  pyproject.toml does not contain a tool.setuptools_scm section                                                                                  setuptools.py:119
collecting: 0/4 workers[03/04/24 08:52:50] WARNING  pyproject.toml does not contain a tool.setuptools_scm section                                                                                  setuptools.py:119
collecting: 0/4 workers[03/04/24 08:52:51] WARNING  pyproject.toml does not contain a tool.setuptools_scm section                                                                                  setuptools.py:119
4 workers [0 items]    errors                                                                                                                                                               
scheduling tests via LoadScheduling
/usr/local/lib/python3.9/site-packages/coverage/inorout.py:507: CoverageWarning: Module nox was never imported. (module-not-imported)
  self.warn(f"Module {pkg} was never imported.", slug="module-not-imported")
/usr/local/lib/python3.9/site-packages/coverage/inorout.py:507: CoverageWarning: Module nox was never imported. (module-not-imported)
  self.warn(f"Module {pkg} was never imported.", slug="module-not-imported")
/usr/local/lib/python3.9/site-packages/coverage/inorout.py:507: CoverageWarning: Module nox was never imported. (module-not-imported)
  self.warn(f"Module {pkg} was never imported.", slug="module-not-imported")
/usr/local/lib/python3.9/site-packages/coverage/control.py:883: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/usr/local/lib/python3.9/site-packages/coverage/control.py:883: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/usr/local/lib/python3.9/site-packages/coverage/inorout.py:507: CoverageWarning: Module nox was never imported. (module-not-imported)
  self.warn(f"Module {pkg} was never imported.", slug="module-not-imported")
/usr/local/lib/python3.9/site-packages/coverage/control.py:883: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/usr/local/lib/python3.9/site-packages/coverage/control.py:883: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
WARNING: Failed to generate report: No data to report.

/usr/local/lib/python3.9/site-packages/pytest_cov/plugin.py:298: CovReportWarning: Failed to generate report: No data to report.

  self.cov_controller.finish()

========================================================================================== ERRORS ===========================================================================================
_______________________________________________________________________________ ERROR collecting test session _______________________________________________________________________________
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:141: in _create
    return super().__call__(*k, **kw)
E   TypeError: __init__() got an unexpected keyword argument 'path'

During handling of the above exception, another exception occurred:
/usr/local/lib/python3.9/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/usr/local/lib/python3.9/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/local/lib/python3.9/site-packages/_pytest/main.py:749: in collect
    for x in self._collectfile(path):
/usr/local/lib/python3.9/site-packages/_pytest/main.py:602: in _collectfile
    return ihook.pytest_collect_file(file_path=fspath, parent=self)  # type: ignore[no-any-return]
/usr/local/lib/python3.9/site-packages/_pytest/config/compat.py:66: in fixed_hook
    return hook(**kw)
/usr/local/lib/python3.9/site-packages/pluggy/_hooks.py:493: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
/usr/local/lib/python3.9/site-packages/pluggy/_manager.py:115: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/usr/local/lib/python3.9/site-packages/pytest_black.py:27: in pytest_collect_file
    return BlackItem.from_parent(parent, fspath=path)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:649: in from_parent
    return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:264: in from_parent
    return cls._create(parent=parent, **kw)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:147: in _create
    warnings.warn(
E   pytest.PytestDeprecationWarning: <class 'pytest_black.BlackItem'> is not using a cooperative constructor and only takes {'parent', 'fspath'}.
E   See https://docs.pytest.org/en/stable/deprecations.html#constructors-of-custom-pytest-node-subclasses-should-take-kwargs for more details.
_______________________________________________________________________________ ERROR collecting test session _______________________________________________________________________________
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:141: in _create
    return super().__call__(*k, **kw)
E   TypeError: __init__() got an unexpected keyword argument 'path'

During handling of the above exception, another exception occurred:
/usr/local/lib/python3.9/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/usr/local/lib/python3.9/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/local/lib/python3.9/site-packages/_pytest/main.py:749: in collect
    for x in self._collectfile(path):
/usr/local/lib/python3.9/site-packages/_pytest/main.py:602: in _collectfile
    return ihook.pytest_collect_file(file_path=fspath, parent=self)  # type: ignore[no-any-return]
/usr/local/lib/python3.9/site-packages/_pytest/config/compat.py:66: in fixed_hook
    return hook(**kw)
/usr/local/lib/python3.9/site-packages/pluggy/_hooks.py:493: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
/usr/local/lib/python3.9/site-packages/pluggy/_manager.py:115: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/usr/local/lib/python3.9/site-packages/pytest_black.py:27: in pytest_collect_file
    return BlackItem.from_parent(parent, fspath=path)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:649: in from_parent
    return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:264: in from_parent
    return cls._create(parent=parent, **kw)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:147: in _create
    warnings.warn(
E   pytest.PytestDeprecationWarning: <class 'pytest_black.BlackItem'> is not using a cooperative constructor and only takes {'parent', 'fspath'}.
E   See https://docs.pytest.org/en/stable/deprecations.html#constructors-of-custom-pytest-node-subclasses-should-take-kwargs for more details.
_______________________________________________________________________________ ERROR collecting test session _______________________________________________________________________________
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:141: in _create
    return super().__call__(*k, **kw)
E   TypeError: __init__() got an unexpected keyword argument 'path'

During handling of the above exception, another exception occurred:
/usr/local/lib/python3.9/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/usr/local/lib/python3.9/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/local/lib/python3.9/site-packages/_pytest/main.py:749: in collect
    for x in self._collectfile(path):
/usr/local/lib/python3.9/site-packages/_pytest/main.py:602: in _collectfile
    return ihook.pytest_collect_file(file_path=fspath, parent=self)  # type: ignore[no-any-return]
/usr/local/lib/python3.9/site-packages/_pytest/config/compat.py:66: in fixed_hook
    return hook(**kw)
/usr/local/lib/python3.9/site-packages/pluggy/_hooks.py:493: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
/usr/local/lib/python3.9/site-packages/pluggy/_manager.py:115: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/usr/local/lib/python3.9/site-packages/pytest_black.py:27: in pytest_collect_file
    return BlackItem.from_parent(parent, fspath=path)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:649: in from_parent
    return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:264: in from_parent
    return cls._create(parent=parent, **kw)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:147: in _create
    warnings.warn(
E   pytest.PytestDeprecationWarning: <class 'pytest_black.BlackItem'> is not using a cooperative constructor and only takes {'fspath', 'parent'}.
E   See https://docs.pytest.org/en/stable/deprecations.html#constructors-of-custom-pytest-node-subclasses-should-take-kwargs for more details.
_______________________________________________________________________________ ERROR collecting test session _______________________________________________________________________________
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:141: in _create
    return super().__call__(*k, **kw)
E   TypeError: __init__() got an unexpected keyword argument 'path'

During handling of the above exception, another exception occurred:
/usr/local/lib/python3.9/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/usr/local/lib/python3.9/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/local/lib/python3.9/site-packages/_pytest/main.py:749: in collect
    for x in self._collectfile(path):
/usr/local/lib/python3.9/site-packages/_pytest/main.py:602: in _collectfile
    return ihook.pytest_collect_file(file_path=fspath, parent=self)  # type: ignore[no-any-return]
/usr/local/lib/python3.9/site-packages/_pytest/config/compat.py:66: in fixed_hook
    return hook(**kw)
/usr/local/lib/python3.9/site-packages/pluggy/_hooks.py:493: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
/usr/local/lib/python3.9/site-packages/pluggy/_manager.py:115: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/usr/local/lib/python3.9/site-packages/pytest_black.py:27: in pytest_collect_file
    return BlackItem.from_parent(parent, fspath=path)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:649: in from_parent
    return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:264: in from_parent
    return cls._create(parent=parent, **kw)
/usr/local/lib/python3.9/site-packages/_pytest/nodes.py:147: in _create
    warnings.warn(
E   pytest.PytestDeprecationWarning: <class 'pytest_black.BlackItem'> is not using a cooperative constructor and only takes {'parent', 'fspath'}.
E   See https://docs.pytest.org/en/stable/deprecations.html#constructors-of-custom-pytest-node-subclasses-should-take-kwargs for more details.

-------- coverage: platform freebsd14, python 3.9.18-final-0 ---------

===================================================================================== 4 errors in 7.94s =====================================================================================
*** Error code 1

Expected Behavior

No response

Steps To Reproduce

No response

Environment

- OS: FreeBSD-14.0
- Python:3.9
- Nox:2024.03.02

Anything else?

No response

cjolowicz commented 6 months ago

Closing for now as this doesn't seem to be a bug in Nox. Feel free to reopen with a minimal repro if you think it is.

Most likely this is pytest-black not being compatible with the pytest release you're using.