Skip to content

8.1.0: testing of pytest fails with installed and disabled plugins #12073

@mtelka

Description

@mtelka
  • a detailed description of the bug or problem you are having

When I run tests for pytest 8.1.0 with some additional pytest plugins installed and disabled, then more than 10 tests fails with errors like:

============================= test session starts ==============================
platform sunos5 -- Python 3.9.18, pytest-8.1.0, pluggy-1.4.0 -- $(BUILD_DIR)/.tox/py39/bin/python
cachedir: .tox/py39/.pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('$(BUILD_DIR)/.hypothesis/examples'))
rootdir: $(BUILD_DIR)
configfile: pyproject.toml
testpaths: testing
plugins: hypothesis-6.98.15, xdist-3.5.0
collecting ... collected 3626 items

... snip ...

__________________ TestConfigFromdictargs.test_basic_behavior __________________

self = <test_config.TestConfigFromdictargs object at 0x7fffaba39610>
_sys_snapshot = None

    def test_basic_behavior(self, _sys_snapshot) -> None:
        option_dict = {"verbose": 444, "foo": "bar", "capture": "no"}
        args = ["a", "b"]

>       config = Config.fromdictargs(option_dict, args)

testing/test_config.py:991:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../prototype/i386/usr/lib/python3.9/vendor-packages/_pytest/config/__init__.py:1192: in fromdictargs
    config.parse(args, addopts=False)
../prototype/i386/usr/lib/python3.9/vendor-packages/_pytest/config/__init__.py:1490: in parse
    self._preparse(args, addopts=addopts)
../prototype/i386/usr/lib/python3.9/vendor-packages/_pytest/config/__init__.py:1377: in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
/usr/lib/python3.9/vendor-packages/pluggy/_manager.py:415: in load_setuptools_entrypoints
    self.register(plugin, name=ep.name)
../prototype/i386/usr/lib/python3.9/vendor-packages/_pytest/config/__init__.py:497: in register
    plugin_name = super().register(plugin, name)
/usr/lib/python3.9/vendor-packages/pluggy/_manager.py:167: in register
    self._verify_hook(hook, hookimpl)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <_pytest.config.PytestPluginManager object at 0x7fffa95f9580>
hook = <HookCaller 'pytest_collect_file'>
hookimpl = <HookImpl plugin_name='black', plugin=<module 'pytest_black' from '/usr/lib/python3.9/vendor-packages/pytest_black.py'>>

    def _verify_hook(self, hook: HookCaller, hookimpl: HookImpl) -> None:
        if hook.is_historic() and (hookimpl.hookwrapper or hookimpl.wrapper):
            raise PluginValidationError(
                hookimpl.plugin,
                "Plugin %r\nhook %r\nhistoric incompatible with yield/wrapper/hookwrapper"
                % (hookimpl.plugin_name, hook.name),
            )

        assert hook.spec is not None
        if hook.spec.warn_on_impl:
            _warn_for_function(hook.spec.warn_on_impl, hookimpl.function)

        # positional arg checking
        notinspec = set(hookimpl.argnames) - set(hook.spec.argnames)
        if notinspec:
>           raise PluginValidationError(
                hookimpl.plugin,
                "Plugin %r for hook %r\nhookimpl definition: %s\n"
                "Argument(s) %s are declared in the hookimpl but "
                "can not be found in the hookspec"
                % ( 
                    hookimpl.plugin_name,
                    hook.name,
                    _formatdef(hookimpl.function),
                    notinspec,
                ),
            )
E           pluggy._manager.PluginValidationError: Plugin 'black' for hook 'pytest_collect_file'
E           hookimpl definition: pytest_collect_file(file_path, path, parent)
E           Argument(s) {'path'} are declared in the hookimpl but can not be found in the hookspec

/usr/lib/python3.9/vendor-packages/pluggy/_manager.py:342: PluginValidationError

In this case the pytest-black plugin is installed and disabled using PYTEST_ADDOPTS=-p 'no:black'.

This is regression since pytest 8.0.2.

  • output of pip list from the virtual environment you are using

The pytest testing is not run in virtual environment, but in real environment.

  • pytest and operating system versions

pytest 8.1.0
OpenIndiana (rolling release, up-to-date)

  • minimal example if possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions