Skip to content

Commit 2bb9fe6

Browse files
committed
use module __getattr__ for py.error to fix doctesting
1 parent ce7045b commit 2bb9fe6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/_pytest/_py/error.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import errno
66
import os
77
import sys
8-
from types import ModuleType
98

109

1110
class Error(EnvironmentError):
@@ -39,7 +38,7 @@ def __str__(self):
3938
}
4039

4140

42-
class ErrorMaker(ModuleType):
41+
class ErrorMaker:
4342
"""lazily provides Exception classes for each possible POSIX errno
4443
(as defined per the 'errno' module). All such instances
4544
subclass EnvironmentError.
@@ -97,5 +96,8 @@ def checked_call(self, func, *args, **kwargs):
9796
__tracebackhide__ = True
9897

9998

100-
error = ErrorMaker("_pytest._py.error")
101-
sys.modules[error.__name__] = error
99+
_error_maker = ErrorMaker()
100+
101+
102+
def __getattr__(attr):
103+
return getattr(_error_maker, attr)

0 commit comments

Comments
 (0)