From 44e9309c8cee525014f93b6b3ba8b77900e58483 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 12 Oct 2025 16:33:40 +0300 Subject: [PATCH] config: set `__module__ = "pytest"` on `UsageError` and `ExitCode` These types occasionally get displayed by their qualified name, let's make it nicer using the user-facing path. --- src/_pytest/config/__init__.py | 2 ++ src/_pytest/config/exceptions.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index afa7e25d84a..8d9282ab37b 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -110,6 +110,8 @@ class ExitCode(enum.IntEnum): #: pytest couldn't find tests. NO_TESTS_COLLECTED = 5 + __module__ = "pytest" + class ConftestImportFailure(Exception): def __init__( diff --git a/src/_pytest/config/exceptions.py b/src/_pytest/config/exceptions.py index 90108eca904..d84a9ea67e0 100644 --- a/src/_pytest/config/exceptions.py +++ b/src/_pytest/config/exceptions.py @@ -7,6 +7,8 @@ class UsageError(Exception): """Error in pytest usage or invocation.""" + __module__ = "pytest" + class PrintHelp(Exception): """Raised when pytest should print its help to skip the rest of the