Merge remote-tracking branch 'upstream/master' into mm
This commit is contained in:
@@ -596,7 +596,7 @@ class ExceptionInfo(Generic[_E]):
|
||||
)
|
||||
return fmt.repr_excinfo(self)
|
||||
|
||||
def match(self, regexp: Union[str, Pattern]) -> bool:
|
||||
def match(self, regexp: "Union[str, Pattern]") -> bool:
|
||||
"""
|
||||
Check whether the regular expression 'regexp' is found in the string
|
||||
representation of the exception using ``re.search``. If it matches
|
||||
|
||||
@@ -35,9 +35,6 @@ PYTEST_TAG = "{}-pytest-{}".format(sys.implementation.cache_tag, version)
|
||||
PYC_EXT = ".py" + (__debug__ and "c" or "o")
|
||||
PYC_TAIL = "." + PYTEST_TAG + PYC_EXT
|
||||
|
||||
AST_IS = ast.Is()
|
||||
AST_NONE = ast.NameConstant(None)
|
||||
|
||||
|
||||
class AssertionRewritingHook(importlib.abc.MetaPathFinder):
|
||||
"""PEP302/PEP451 import hook which rewrites asserts."""
|
||||
@@ -863,7 +860,7 @@ class AssertionRewriter(ast.NodeVisitor):
|
||||
internally already.
|
||||
See issue #3191 for more details.
|
||||
"""
|
||||
val_is_none = ast.Compare(node, [AST_IS], [AST_NONE])
|
||||
val_is_none = ast.Compare(node, [ast.Is()], [ast.NameConstant(None)])
|
||||
send_warning = ast.parse(
|
||||
"""\
|
||||
from _pytest.warning_types import PytestAssertRewriteWarning
|
||||
|
||||
@@ -9,6 +9,7 @@ import sys
|
||||
from contextlib import contextmanager
|
||||
from inspect import Parameter
|
||||
from inspect import signature
|
||||
from typing import overload
|
||||
|
||||
import attr
|
||||
import py
|
||||
@@ -27,9 +28,9 @@ MODULE_NOT_FOUND_ERROR = (
|
||||
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from importlib import metadata as importlib_metadata # noqa
|
||||
from importlib import metadata as importlib_metadata # noqa: F401
|
||||
else:
|
||||
import importlib_metadata # noqa
|
||||
import importlib_metadata # noqa: F401
|
||||
|
||||
|
||||
def _format_args(func):
|
||||
@@ -347,3 +348,9 @@ class FuncargnamesCompatAttr:
|
||||
|
||||
warnings.warn(FUNCARGNAMES, stacklevel=2)
|
||||
return self.fixturenames
|
||||
|
||||
|
||||
if sys.version_info < (3, 5, 2): # pragma: no cover
|
||||
|
||||
def overload(f): # noqa: F811
|
||||
return f
|
||||
|
||||
@@ -72,7 +72,7 @@ def create_new_paste(contents):
|
||||
if m:
|
||||
return "{}/show/{}".format(url, m.group(1))
|
||||
else:
|
||||
return "bad response: " + response
|
||||
return "bad response: " + response.decode("utf-8")
|
||||
|
||||
|
||||
def pytest_terminal_summary(terminalreporter):
|
||||
|
||||
@@ -13,7 +13,6 @@ from typing import Callable
|
||||
from typing import cast
|
||||
from typing import Generic
|
||||
from typing import Optional
|
||||
from typing import overload
|
||||
from typing import Pattern
|
||||
from typing import Tuple
|
||||
from typing import TypeVar
|
||||
@@ -22,12 +21,14 @@ from typing import Union
|
||||
from more_itertools.more import always_iterable
|
||||
|
||||
import _pytest._code
|
||||
from _pytest.compat import overload
|
||||
from _pytest.compat import STRING_TYPES
|
||||
from _pytest.outcomes import fail
|
||||
|
||||
if False: # TYPE_CHECKING
|
||||
from typing import Type # noqa: F401 (used in type string)
|
||||
|
||||
|
||||
BASE_TYPE = (type, STRING_TYPES)
|
||||
|
||||
|
||||
@@ -547,12 +548,12 @@ _E = TypeVar("_E", bound=BaseException)
|
||||
def raises(
|
||||
expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]],
|
||||
*,
|
||||
match: Optional[Union[str, Pattern]] = ...
|
||||
match: "Optional[Union[str, Pattern]]" = ...
|
||||
) -> "RaisesContext[_E]":
|
||||
... # pragma: no cover
|
||||
|
||||
|
||||
@overload
|
||||
@overload # noqa: F811
|
||||
def raises(
|
||||
expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]],
|
||||
func: Callable,
|
||||
@@ -563,10 +564,10 @@ def raises(
|
||||
... # pragma: no cover
|
||||
|
||||
|
||||
def raises(
|
||||
def raises( # noqa: F811
|
||||
expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]],
|
||||
*args: Any,
|
||||
match: Optional[Union[str, Pattern]] = None,
|
||||
match: Optional[Union[str, "Pattern"]] = None,
|
||||
**kwargs: Any
|
||||
) -> Union["RaisesContext[_E]", Optional[_pytest._code.ExceptionInfo[_E]]]:
|
||||
r"""
|
||||
@@ -724,7 +725,7 @@ class RaisesContext(Generic[_E]):
|
||||
self,
|
||||
expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]],
|
||||
message: str,
|
||||
match_expr: Optional[Union[str, Pattern]] = None,
|
||||
match_expr: Optional[Union[str, "Pattern"]] = None,
|
||||
) -> None:
|
||||
self.expected_exception = expected_exception
|
||||
self.message = message
|
||||
|
||||
@@ -7,11 +7,11 @@ from typing import Callable
|
||||
from typing import Iterator
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
from typing import overload
|
||||
from typing import Pattern
|
||||
from typing import Tuple
|
||||
from typing import Union
|
||||
|
||||
from _pytest.compat import overload
|
||||
from _pytest.fixtures import yield_fixture
|
||||
from _pytest.outcomes import fail
|
||||
|
||||
@@ -58,26 +58,26 @@ def deprecated_call(func=None, *args, **kwargs):
|
||||
def warns(
|
||||
expected_warning: Union["Type[Warning]", Tuple["Type[Warning]", ...]],
|
||||
*,
|
||||
match: Optional[Union[str, Pattern]] = ...
|
||||
match: "Optional[Union[str, Pattern]]" = ...
|
||||
) -> "WarningsChecker":
|
||||
... # pragma: no cover
|
||||
|
||||
|
||||
@overload
|
||||
@overload # noqa: F811
|
||||
def warns(
|
||||
expected_warning: Union["Type[Warning]", Tuple["Type[Warning]", ...]],
|
||||
func: Callable,
|
||||
*args: Any,
|
||||
match: Optional[Union[str, Pattern]] = ...,
|
||||
match: Optional[Union[str, "Pattern"]] = ...,
|
||||
**kwargs: Any
|
||||
) -> Union[Any]:
|
||||
... # pragma: no cover
|
||||
|
||||
|
||||
def warns(
|
||||
def warns( # noqa: F811
|
||||
expected_warning: Union["Type[Warning]", Tuple["Type[Warning]", ...]],
|
||||
*args: Any,
|
||||
match: Optional[Union[str, Pattern]] = None,
|
||||
match: Optional[Union[str, "Pattern"]] = None,
|
||||
**kwargs: Any
|
||||
) -> Union["WarningsChecker", Any]:
|
||||
r"""Assert that code raises a particular class of warning.
|
||||
@@ -207,7 +207,7 @@ class WarningsChecker(WarningsRecorder):
|
||||
expected_warning: Optional[
|
||||
Union["Type[Warning]", Tuple["Type[Warning]", ...]]
|
||||
] = None,
|
||||
match_expr: Optional[Union[str, Pattern]] = None,
|
||||
match_expr: Optional[Union[str, "Pattern"]] = None,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user