Update __init__.py

This commit is contained in:
apanayotova03 2024-06-18 21:48:49 +02:00
parent dc65bb6a66
commit 045230a428
1 changed files with 13 additions and 7 deletions

View File

@ -46,15 +46,16 @@ from pluggy import HookspecMarker
from pluggy import HookspecOpts from pluggy import HookspecOpts
from pluggy import PluginManager from pluggy import PluginManager
from .compat import PathAwareHookProxy # from .compat import PathAwareHookProxy
from .exceptions import PrintHelp as PrintHelp # from .exceptions import PrintHelp as PrintHelp
from .exceptions import UsageError as UsageError # from .exceptions import UsageError as UsageError
from .findpaths import determine_setup # from .findpaths import determine_setup
from _pytest import __version__ from _pytest import __version__
import _pytest._code import _pytest._code
from _pytest._code import ExceptionInfo from _pytest._code import ExceptionInfo
from _pytest._code import filter_traceback from _pytest._code import filter_traceback
from _pytest._code.code import TracebackStyle
# from _pytest._code.code import TracebackStyle
from _pytest._io import TerminalWriter from _pytest._io import TerminalWriter
from _pytest.config.argparsing import Argument from _pytest.config.argparsing import Argument
from _pytest.config.argparsing import Parser from _pytest.config.argparsing import Parser
@ -91,6 +92,9 @@ Ideally this type would be provided by pluggy itself.
hookimpl = HookimplMarker("pytest") hookimpl = HookimplMarker("pytest")
hookspec = HookspecMarker("pytest") hookspec = HookspecMarker("pytest")
@final # I added
class UsageError(Exception):
"""Error in pytest usage or invocation."""
@final @final
class ExitCode(enum.IntEnum): class ExitCode(enum.IntEnum):
@ -799,7 +803,7 @@ class PytestPluginManager(PluginManager):
if arg.startswith("no:"): if arg.startswith("no:"):
name = arg[3:] name = arg[3:]
if name in essential_plugins: if name in essential_plugins:
raise UsageError(f"plugin {name} cannot be disabled") print(f"UsageError: plugin {name} cannot be disabled")
# PR #4304: remove stepwise if cacheprovider is blocked. # PR #4304: remove stepwise if cacheprovider is blocked.
if name == "cacheprovider": if name == "cacheprovider":
@ -809,10 +813,12 @@ class PytestPluginManager(PluginManager):
self.set_blocked(name) self.set_blocked(name)
if not name.startswith("pytest_"): if not name.startswith("pytest_"):
self.set_blocked("pytest_" + name) self.set_blocked("pytest_" + name)
else: else:
name = arg name = arg
# Unblock the plugin. # Unblock the plugin.
self.unblock(name) self.unblock(name)
if not name.startswith("pytest_"): if not name.startswith("pytest_"):
self.unblock("pytest_" + name) self.unblock("pytest_" + name)
self.import_plugin(arg, consider_entry_points=True) self.import_plugin(arg, consider_entry_points=True)