fixed(raises) for failing test cases

This commit is contained in:
Virendra Patil 2024-06-24 09:58:19 +05:30
parent db66af8d49
commit 3d7a598eb2
1 changed files with 19 additions and 19 deletions

View File

@ -1,32 +1,32 @@
# mypy: allow-untyped-defs # mypy: allow-untyped-defs
from __future__ import annotations from __future__ import annotations
from collections.abc import Collection
from collections.abc import Sized
from decimal import Decimal
import math import math
from numbers import Complex
import pprint import pprint
import re import re
from collections.abc import Collection, Sized
from decimal import Decimal
from numbers import Complex
from types import TracebackType from types import TracebackType
from typing import Any from typing import (
from typing import Callable TYPE_CHECKING,
from typing import cast Any,
from typing import ContextManager Callable,
from typing import final ContextManager,
from typing import Mapping Mapping,
from typing import overload Pattern,
from typing import Pattern Sequence,
from typing import Sequence Tuple,
from typing import Tuple Type,
from typing import Type TypeVar,
from typing import TYPE_CHECKING cast,
from typing import TypeVar final,
overload,
)
import _pytest._code import _pytest._code
from _pytest.outcomes import fail from _pytest.outcomes import fail
if TYPE_CHECKING: if TYPE_CHECKING:
from numpy import ndarray from numpy import ndarray
@ -1008,7 +1008,7 @@ class RaisesContext(ContextManager[_pytest._code.ExceptionInfo[E]]):
exc_info = cast(Tuple[Type[E], E, TracebackType], (exc_type, exc_val, exc_tb)) exc_info = cast(Tuple[Type[E], E, TracebackType], (exc_type, exc_val, exc_tb))
self.excinfo.fill_unfilled(exc_info) self.excinfo.fill_unfilled(exc_info)
try: try:
if self.match_expr: if self.match_expr is not None:
self.excinfo.match(self.match_expr) self.excinfo.match(self.match_expr)
except re.error as e: except re.error as e:
fail(f"Invalid regex pattern provided to 'match': {e}") fail(f"Invalid regex pattern provided to 'match': {e}")