From 5b4df5e295cd80f5e25653f7a045ce60f4fc4028 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 8 Oct 2022 06:22:53 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytest/_io/saferepr.py | 4 +++- src/_pytest/assertion/util.py | 10 ++++++++-- testing/test_assertion.py | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/_pytest/_io/saferepr.py b/src/_pytest/_io/saferepr.py index 07159e7b3..c1bb3ae8f 100644 --- a/src/_pytest/_io/saferepr.py +++ b/src/_pytest/_io/saferepr.py @@ -94,7 +94,9 @@ def safeformat(obj: object) -> str: DEFAULT_REPR_MAX_SIZE = 240 -def saferepr(obj: object, maxsize: Optional[int] = DEFAULT_REPR_MAX_SIZE, use_ascii: bool = False) -> str: +def saferepr( + obj: object, maxsize: Optional[int] = DEFAULT_REPR_MAX_SIZE, use_ascii: bool = False +) -> str: """Return a size-limited safe repr-string for the given object. Failing __repr__ functions of user instances will be represented diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index a854f7171..32ad03e78 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -157,11 +157,17 @@ def has_default_eq( return True -def assertrepr_compare(config, op: str, left: Any, right: Any, use_ascii: bool=False) -> Optional[List[str]]: +def assertrepr_compare( + config, op: str, left: Any, right: Any, use_ascii: bool = False +) -> Optional[List[str]]: """Return specialised explanations for some operators/operands.""" verbose = config.getoption("verbose") - use_ascii = isinstance(left, str) and isinstance(right, str) and normalize("NFD", left) == normalize("NFD", right) + use_ascii = ( + isinstance(left, str) + and isinstance(right, str) + and normalize("NFD", left) == normalize("NFD", right) + ) if verbose > 1: left_repr = saferepr_unlimited(left, use_ascii=use_ascii) diff --git a/testing/test_assertion.py b/testing/test_assertion.py index d0f266769..e253144a2 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -781,7 +781,11 @@ class TestAssert_reprcompare: left = "hyv\xe4" right = "hyva\u0308" expl = callequal(left, right) - assert expl == ['"\'hyv\\\\xe4\'" == "\'hyva\\\\u0308\'"', f'- {str(right)}', f'+ {str(left)}'] + assert expl == [ + "\"'hyv\\\\xe4'\" == \"'hyva\\\\u0308'\"", + f"- {str(right)}", + f"+ {str(left)}", + ] class TestAssert_reprcompare_dataclass: