{"id":"bc2502a6c31cd162","repo":"pytest-dev/pytest","slug":"blocking-conftest-files-using-p-is-not-supported","errorCode":null,"errorMessage":"Blocking conftest files using -p is not supported: -p no:{name}\nconftest.py files are not plugins and cannot be disabled via -p.\n","messagePattern":"Blocking conftest files using -p is not supported: -p no:(.+?)\nconftest\\.py files are not plugins and cannot be disabled via -p\\.\n","errorType":"validation","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":852,"sourceCode":"                    i += 1\n                elif opt.startswith(\"-p\"):\n                    parg = opt[2:]\n                else:\n                    continue\n                parg = parg.strip()\n                if exclude_only and not parg.startswith(\"no:\"):\n                    continue\n                self.consider_pluginarg(parg)\n\n    def consider_pluginarg(self, arg: str) -> None:\n        \"\"\":meta private:\"\"\"\n        if arg.startswith(\"no:\"):\n            name = arg[3:]\n            if name in essential_plugins:\n                raise UsageError(f\"plugin {name} cannot be disabled\")\n\n            if name.endswith(\"conftest.py\"):\n                raise UsageError(\n                    f\"Blocking conftest files using -p is not supported: -p no:{name}\\n\"\n                    \"conftest.py files are not plugins and cannot be disabled via -p.\\n\"\n                )\n\n            # PR #4304: remove stepwise if cacheprovider is blocked.\n            if name == \"cacheprovider\":\n                self.set_blocked(\"stepwise\")\n                self.set_blocked(\"pytest_stepwise\")\n\n            self.set_blocked(name)\n            if not name.startswith(\"pytest_\"):\n                self.set_blocked(\"pytest_\" + name)\n        else:\n            name = arg\n            # Unblock the plugin.\n            self.unblock(name)\n            if not name.startswith(\"pytest_\"):\n                self.unblock(\"pytest_\" + name)","sourceCodeStart":834,"sourceCodeEnd":870,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/__init__.py#L834-L870","documentation":"conftest.py files are loaded by pytest's collection mechanism, not the plugin system, so they cannot be blocked with -p no:. If the name passed to -p no: ends with 'conftest.py', pytest raises UsageError explaining the distinction. This prevents users from misunderstanding the plugin architecture.","triggerScenarios":"Running pytest with a flag like -p no:conftest.py or -p no:tests/conftest.py. The name.endswith('conftest.py') check is True, so UsageError is raised.","commonSituations":"Users trying to suppress a conftest.py that interferes with a test run, or misunderstanding -p no: as a general file-blocking mechanism.","solutions":["Use --noconftest to prevent conftest.py files from being loaded.","Move or rename the conftest.py if it should not apply to the current run.","Use -p no:<plugin_name> only for actual plugins, not conftest.py files."],"exampleFix":"# before\npytest -p no:tests/conftest.py\n\n# after\npytest --noconftest","handlingStrategy":"validation","validationCode":"def is_conftest_name(name: str) -> bool:\n    return name.endswith('conftest.py')\n\n# Do not attempt -p no:<name> if is_conftest_name(name); use --noconftest instead.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use --noconftest to suppress all conftest.py loading.","Never pass a conftest.py path to -p no:; conftest files are handled by the collection system, not the plugin system."],"tags":["config","cli","plugins","conftest","usage-error"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}